This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes An ActionForm populated in one Action is not getting its values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "An ActionForm populated in one Action is not getting its values" Watch "An ActionForm populated in one Action is not getting its values" New topic
Author

An ActionForm populated in one Action is not getting its values

Mallika R Kumar
Ranch Hand

Joined: Jan 21, 2004
Posts: 38
Hi,
I have a LoginAction, that uses the form bean loginForm, consisting of loginname and password fields. On a successful login, I am displaying a logged in user's activity. So, in the LoginAction, I am populating userActivity form bean, settings its action property to be "showactivity". I'm setting this userActivity form bean in the request attribute with the name specified in struts-config.xml. The execution is then passed onto success actionForward for LoginAction, which points to the ShowAction, expecting userActivity form bean.
With logging on, what I see is that the userActivity form bean is being picked up from LoginAction, but values being populated are loginname and password, and not action field.
What am I missing here ? What I want to do here is to populate userActivity form bean from LoginAction, pass execution to ShowAction and let it display results, rather that LoginAction doing the processing for displaying a user's activity.
Thanks for the help.

Mallika.
Sarath Mohan
Ranch Hand

Joined: Mar 17, 2001
Posts: 213

So, in the LoginAction, I am populating userActivity form bean, settings its action property to be "showactivity". I'm setting this userActivity form bean in the request attribute with the name specified in struts-config.xml.


Oops! The Struts framework will map & poplate fields Action Form declared in the struts-config file.This will happen every time when the respective action is invoked. So even if you put something into the actionForm it won't be available.

Could you be more what functionality to achieve. This may help us to give you a better solution


Sarath Mohan
Mallika R Kumar
Ranch Hand

Joined: Jan 21, 2004
Posts: 38
Hi Sarath,
I'm trying to execute a method belonging to ShowAction, in LoginAction. I know its not advisable to create an instance of ShowAction class in LoginAction, and call ShowAction's execute, passing the necessary parameters. Creating instances of Action classes is the job for Struts RequestProcessor. But I thought I should be able to create an instance of a FormBean, and pass it to another Action class, by declaring actionForward to be another Action class in struts-config. I am unable to get the values I populated in the form bean. With Struts logging, I see that the form bean I created is being picked up, rather than a new instance being created. But the values are puzzling me. FormBean for ShowAction does not have loginname and password members, but Struts tells me its populating those.
What I'm doing now is repeating the function in LoginAction and ShowAction, whereas, ideally, I would like LoginAction to send control to ShowAction, and let ShowAction do the processing for this functionality.
Is this not a good idea ?

Mallika.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: An ActionForm populated in one Action is not getting its values
 
Similar Threads
Actionform not populating JSP
Removing HttpServletRequest parameters
How to fill values in selectbox dynamically
Action Form Problem
form values not showing in jsp