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.
The moose likes Struts and the fly likes 1 Form 2 Actions both cant be request? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "1 Form 2 Actions both cant be request?" Watch "1 Form 2 Actions both cant be request?" New topic
Author

1 Form 2 Actions both cant be request?

Shane Johnson
Greenhorn

Joined: Jan 20, 2005
Posts: 3
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?

Shane
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Are these two populating-actions chained together or are either of them chained together with a submitting-action that also uses the same ActionForm?


A good workman is known by his tools.
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4782
    
    8

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 ]

Junilu - [How to Ask Questions] [How to Answer Questions]
Shane Johnson
Greenhorn

Joined: Jan 20, 2005
Posts: 3
here is are three of the actions:

<action path="/someAction"
type="my.company.someactionclass"
name="someform" scope="request" validate="false">
<forward name="success" path="/actionA.do" />
</action>

<action path="/actionA"
type="my.company.actionclassA"
name="theform" validate="false">
<forward name="success" path="jspA" />
</action>

<action path="/actionB"
type="my.company.actionclassB"
name="theform" scope="request" validate="false">
<forward name="success" path="jspB" />
</action>

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.

i hope clarified your above comments.

shane
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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.
 
 
subject: 1 Form 2 Actions both cant be request?