• 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

populating forms, sry :(

Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for this question, but i dont clearly understand the process of populating forms on struts.
I have a jsp where user can update his/her profile like username, email etc.
I know struts can populate this form. I have this data stored in database.
I did like this. I have an action class lets say ProfileAction which is mapped to profileAction.do. This class calls this jsp with form to be populated.

Then i have ActionForm bean with all gets sets methods of jsp's form fields. And i have another UpdateProfileAction with mapping "updateProfile.do". This where submit goes and i do here all update queries.
The question is: do i have to put in request in ProfileAction class all the stuff i want to be populated?
Thx in advance...
[reformatted by |10dr]
[ March 19, 2004: Message edited by: Junilu Lacar ]
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope I'm following your question correctly.
Your flow is:
ProfileAction -> .jsp -> UpdateProfileAction
And you are asking how to pre-populate the .jsp with data?
If no, please restate your question.
If yes, you can either attach the ProfileActionForm in your struts-config.xml to the ProfileAction (in addition to UpdateProfileAction).
Then, in your ProfileAction.execute() get a reference to the form through the ActionForm parameter passed in, call your set functions on the data and forward onto the .jsp.
Or in your ProfileAction class, instantiate your ActionForm, populate it with the data and set the form in the appropriate scope with the EXACT same name as you gave it in the struts-config.xml file.
I hope this helps.
Ilja Smoli
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx for reply.
You got my flow and question correctly.
First way you offer is smth. like:

Actually I tried this, but ProfileActionForm was attached only to second action. My fault
Unfortunately I can't try this code now and tell is it ok or not.
Im not fully understood second way, it'll be great if u can provide example of it. As I see difference is that in second way i put whole form in a scope (request, session). True?
Posts: 15888
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest you go through this tutorial to get a better understanding of the flow and responsibilities of the different components that are involved in Struts.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic