Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

1 Form 2 Actions both cant be request?

 
Shane Johnson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are these two populating-actions chained together or are either of them chained together with a submitting-action that also uses the same ActionForm?
 
Junilu Lacar
Bartender
Posts: 7333
45
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Shane Johnson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic