I am new to
Struts and need some help understanding how to best pre-fill an ActionForm. At a high level, I created a
jsp page, ActionForm and Action for some user information. The form, field validations, etc... all work well as expected. I would like to implement an edit function that would pre-load the user information onto the form and allow the user to update. I have the update portion of the code working (saving updates to database), but have not figured out how to get the form to pre-load the user info. I have developed a User object stored in the session with getter, setter, save, initialize, etc... methods.
Questions:
1) Should the pre-loading occur in the ActionForm or the Action?
- If in the ActionForm, how can I access the session to retrieve the User object?
- If in the Action, where and how can it be done? In the execute method of the Action, I can use the request object to get to the session, but the execute method only seems to execute after the form passes the validation process, not when the jsp/ActionForm is first initialized.
2) I tried importing the User Object onto the jsp page, but when I use the html:text tag in conjunction with the bean:write tag, it gives me an error referring to no bean found in scope. If I need to declare the the User object as the page bean object, how do I go about doing so?
I can upload the Action/ActionForm/jsp code and the struts config if needed, but I was hoping to get a high level understanding of how to best approach this scenario. Please let me know if you need the code and configuration files to help answer my question?
Thank you