I want to have a form where registered users can edit their details.
This means the form has to be pre-populated with the users data. Do I simply need to set the values of the form bean from the DB in advance to do this? If so, how do I do that?
If I'm way off track - can someone give me some clues Please? This is the last thing I need to do to get my web app running!
-
Using existing data in a Struts form (2 messages)
- Posted by: Paul Hunnisett
- Posted on: February 17 2004 04:33 EST
Threaded Messages (2)
- Using existing data in a Struts form by Mircea Crisan on February 17 2004 10:35 EST
- Using existing data in a Struts form by MAHENDER PEDDI on February 24 2004 05:37 EST
-
Using existing data in a Struts form[ Go to top ]
- Posted by: Mircea Crisan
- Posted on: February 17 2004 10:35 EST
- in response to Paul Hunnisett
Hi,
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
UserForm userForm = (UserForm) form;
.......
//populate user form with data retrieved from db
userForm.setFirstName(...);
userForm.setLastName(...);
userForm.setEmail(...);
.....
request.setAttribute("userForm", userForm);
return mapping.findForward("success");
}
Best regards, Mircea -
Using existing data in a Struts form[ Go to top ]
- Posted by: MAHENDER PEDDI
- Posted on: February 24 2004 05:37 EST
- in response to Mircea Crisan
Hi Paul
What you are planning to do is absolutely right. If you have some problems in setting some data you can directly set it to the session object and access the data from the session object. Dont forget to remove the session attribute after you have used the data. Otherwise it will create some performance problems
You can do it in this was
<html:text property="aa" value="{sessionattribute}"/>