You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Denis Fefermann <FE...@de.ibm.com> on 2009/04/17 19:35:33 UTC

Calling Action on page load

Hi all,

I am new to STRUTS and to this mailinglist, so please be patient with me.

What I am trying, is to call an action on jsp load.
I guess I need a javasript function which calls an action and 'onload' in 
my body.

function callAction{
 
        ... calling   myAction.do

}

<body onload="callAction();" ... >

Can somebody help me with this issue?

thank you

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Calling Action on page load

Posted by Martin Gainty <mg...@hotmail.com>.
if you're bound by political considerations to use Struts1 use Dave's suggestion
(if you are able to implement Struts2 solutuion use the suggestion I posted yesterday)

please keep us apprised
Martin 
______________________________________________ 
Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité 
This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.






> To: user@struts.apache.org
> Subject: Re: Calling Action on page load
> From: FEFERMAN@de.ibm.com
> Date: Mon, 20 Apr 2009 09:40:28 +0200
> 
> Thank you all for the hints. I will try again as soon as I'll get fit.
> 
> 
> 
> 
> 
> 
> Denis Fefermann wrote:
> > I am using Struts 1 and no JavaScript Frameworks.  I do not need data 
> from 
> > calling the action.
> > The point is, everytime I refresh my JSP Page , I need to increment  a 
> > sort of a counter in my Action Class. 
> 
> So increment a counter in your action class, put it in session/request 
> scope, and display it on the page that way.
> 
> Dave
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Rediscover Hotmail®: Now available on your iPhone or BlackBerry
http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Mobile2_042009

Re: Calling Action on page load

Posted by Denis Fefermann <FE...@de.ibm.com>.
Thank you all for the hints. I will try again as soon as I'll get fit.






Denis Fefermann wrote:
> I am using Struts 1 and no JavaScript Frameworks.  I do not need data 
from 
> calling the action.
> The point is, everytime I refresh my JSP Page , I need to increment  a 
> sort of a counter in my Action Class. 

So increment a counter in your action class, put it in session/request 
scope, and display it on the page that way.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Calling Action on page load

Posted by Dave Newton <ne...@yahoo.com>.
Denis Fefermann wrote:
> I am using Struts 1 and no JavaScript Frameworks.  I do not need data from 
> calling the action.
> The point is, everytime I refresh my JSP Page , I need to increment  a 
> sort of a counter in my Action Class. 

So increment a counter in your action class, put it in session/request 
scope, and display it on the page that way.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Calling Action on page load

Posted by Denis Fefermann <FE...@de.ibm.com>.
I am using Struts 1 and no JavaScript Frameworks.  I do not need data from 
calling the action.
The point is, everytime I refresh my JSP Page , I need to increment  a 
sort of a counter in my Action Class. 




On Friday 17 April 2009 13:35:33 Denis Fefermann wrote:
> Hi all,
>
> I am new to STRUTS and to this mailinglist, so please be patient with 
me.
>
> What I am trying, is to call an action on jsp load.
> I guess I need a javasript function which calls an action and 'onload' 
in
> my body.
>
> function callAction{
>
>         ... calling   myAction.do
>
> }
>
> <body onload="callAction();" ... >
>
> Can somebody help me with this issue?
>
> thank you

Struts 1 or Struts 2? Since you have the '.do' extension, I would assume 
Struts 1. Do you plan to do something with the data returned from calling 
the 
action? Also, are you using any particular JavaScript framework? 
Frameworks 
like JQuery provide easy-to-use methods for making Asynchronous HTTP 
Requests. 

-Wes

-- 

Wes Wannemacher
Author - Struts 2 In Practice 
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Calling Action on page load

Posted by Wes Wannemacher <we...@wantii.com>.
On Friday 17 April 2009 13:35:33 Denis Fefermann wrote:
> Hi all,
>
> I am new to STRUTS and to this mailinglist, so please be patient with me.
>
> What I am trying, is to call an action on jsp load.
> I guess I need a javasript function which calls an action and 'onload' in
> my body.
>
> function callAction{
>
>         ... calling   myAction.do
>
> }
>
> <body onload="callAction();" ... >
>
> Can somebody help me with this issue?
>
> thank you

Struts 1 or Struts 2? Since you have the '.do' extension, I would assume 
Struts 1. Do you plan to do something with the data returned from calling the 
action? Also, are you using any particular JavaScript framework? Frameworks 
like JQuery provide easy-to-use methods for making Asynchronous HTTP Requests. 

-Wes

-- 

Wes Wannemacher
Author - Struts 2 In Practice 
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Calling Action on page load

Posted by Wes Wannemacher <we...@wantii.com>.
+1

Having a clear line between view and service promotes this sort of reuse.


On 4/17/09, Dave Newton <ne...@yahoo.com> wrote:
> Denis Fefermann wrote:
>> Hi all,
>>
>> I am new to STRUTS and to this mailinglist, so please be patient with me.
>>
>> What I am trying, is to call an action on jsp load.
>> I guess I need a javasript function which calls an action and 'onload' in
>> my body.
>>
>> function callAction{
>>
>>         ... calling   myAction.do
>>
>> }
>>
>> <body onload="callAction();" ... >
>>
>> Can somebody help me with this issue?
>
> In addition to Wes's comments/questions, I'd examine the perceived need
> for this pretty closely and see if there wasn't another way to do it:
> depending on the use-case it sounds suspiciously like something that
> could be wrapped up in a service call and exposed in the action itself.
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

-- 
Sent from my mobile device

Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Calling Action on page load

Posted by Dave Newton <ne...@yahoo.com>.
Denis Fefermann wrote:
> Hi all,
> 
> I am new to STRUTS and to this mailinglist, so please be patient with me.
> 
> What I am trying, is to call an action on jsp load.
> I guess I need a javasript function which calls an action and 'onload' in 
> my body.
> 
> function callAction{
>  
>         ... calling   myAction.do
> 
> }
> 
> <body onload="callAction();" ... >
> 
> Can somebody help me with this issue?

In addition to Wes's comments/questions, I'd examine the perceived need 
for this pretty closely and see if there wasn't another way to do it: 
depending on the use-case it sounds suspiciously like something that 
could be wrapped up in a service call and exposed in the action itself.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org