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.
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
Mallika R Kumar
Joined: Jan 21, 2004
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 ?
subject: An ActionForm populated in one Action is not getting its values