This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I have two actions that share the same form, and both actions serve to populate this form (it is a map backed form). However, if i set both of them with the scope being request, then only the second action will prepopulate the form. If i set the second action to request and leave the the first one unspecified (session?) then they both prepopulate just fine. Each form prepoluates and forwards to a different jsp. Is there a reason by the prepopulating does not take place if both actions are request scoped?
Originally posted by Shane Johnson: ... if i set both of them with the scope being request, then only the second action will prepopulate the form. If i set the second action to request and leave the the first one unspecified (session?) then they both prepopulate just fine. ... Is there a reason by the prepopulating does not take place if both actions are request scoped?
Be default, the form will be in the request scope; specifying request scope explicitly should not make a difference. Not sure why it is in your case. Is there any other difference in the configuration?
EDIT: (correction, see Marc's post below), the framework default scope is session. [ January 21, 2005: Message edited by: Junilu Lacar ]
we start with someAction that gets a form and basically saves the data. lets say we were on a page that asked for a persons info and when we submitted we save that person. that action then calls actionA which will load a map backed form with some data we need to show on jspA. there is a link on jspA that will perform actionB that will then show us some different data on jspB.
what you see above works just fine. if we add the phrase 'scope="request"' in the definition for actionA then actionA does prepopulate anymore. if i remove this phrase from actionB then actionB does not prepopulate anymore.
Read section 4.3 - this says that session is the default scope. The source code also shows the logic of "if request is specified, set to request else set to session". Finally, the default value in the ActionConfig class is: protected String scope = "session";
Anyway, it's hard to say from the surface what could be causing the issues. I do admire your patience for how many times you've probably restarted your server on each tweak of the struts-config file.
There has got to be something deeper causing the problem. It seems weird that you are using a map-backed form to display information about a single student.