• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Regarding actionform & its request

 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

I am learning struts. I have a doubt about the Action Form when its in Request scope.
I hav a url which maps to an Action say FirstAction. I have associated a form ShareForm with this action FirstAction. The scope of the ShareForm is request. In FirstAction I retrieve all the details of the attributes in the ShareForm.
Now from FirstAction I have forwarded to a new action SecondAction which also has the same form (ShareForm). My question is will the data which i retrieved in FirstAction from the ShareForm will also be available to SecondAction or is it that the form would be reset before being used in SecondAction.

I have seen a bit conflicting behavior so just wanted to clarify

Regards,
Manish
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the user presses the submit button on the Jsp1, all inputs on that form are populated into ShareForm. If FistAction puts data into ShareForm for which there is no input on JSP1, that data is lost.
 
manish ahuja
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Merrill

Thanks for the reply.

Correct me if I am wrong here.

I am not modifying the form in the FirstAction.
I will only fetch values from it & then forward it to the secondAction.
So in this case the expected behavior is that the form is available in the secondAction in the same way as it was in the FirstAction with all values intact.

And if i modify the form in the firstAction then all the form values which the form had when it was populated in initial input JSP & fetched in the firstAction would be reset & what i get in the secondAction is the new instance of the ShareForm.

Thanks & Regards

Manish
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is basically correct. However, I would like to clarify one point:

Regardless of whether you change the values or not, the instance of ShareForm that SecondAction receives will always be a new instance if the ActionForm is in request scope. When the JSP is submitted, Struts creates a new instance of the ActionForm and repopulates it with the input values from the JSP.
 
Don't play dumb with me! But you can try this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic