Hi 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 ]
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.
posted 16 years ago
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? Thx