Hi there,
It looks to me like you need to include a form bean reference in your
action so that Struts will instantiate the (intially empty) form bean.This
means that
((DynaActionForm)form).set("registerFull", registerDTO);
actually has a form object to work with. Presumably you have a form bean
definition in your struts-config so just
reference it in the usual way in the action definition for /Register2.
Your second problem is that you need to copy the properties out of the DTO
into the action form, rather then setting the entire
DTO as a property of the action form. As it stands, your html tags won't
actually find any of the properties.
You may be able to use
BeanUtils.copyProperties(form,registerDTO);
Ross
> {
> ComplRegisterDTO userDataDTO = new ComplRegisterDTO();
> HttpSession session = request.getSession();
> User u = (User) session.getAttribute("user");
> userDataDTO.setId(u.getUserId());
> userDataDTO.setFullname(u.getFullname());
> ...
>return userDataDTO;
> }
- Original Message -
From: "Jiri Chaloupka" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Saturday, August 30, 2003 9:09 AM
Subject: load data into form for editation
> Hallo,
> what is the correct way to load data from db into form?
>
> I have some form:
>
>
>
> :
>
>
>
> :
>
>
> etc...
>
> ,
> action class as:
> public class LoadDataAction extends Action {
>
> public ActionForward execute(ActionMapping mapping,
> ActionForm form,
> HttpServletRequest request,
> HttpServletResponse response)
> throws Exception, DatabaseException
> {
>
> LoadDataService service = new LoadDataService();
> ComplRegisterDTO registerDTO = service.loadUser(request);
>
> ((DynaActionForm)form).set("registerFull", registerDTO);
>
> return (mapping.findForward("success"));
> }
> }
>
> Service class as:
> public class LoadDataService {
>
> public ComplRegisterDTO loadUser(HttpServletRequest request) throws
> Exception
> {
> ComplRegisterDTO userDataDTO = new ComplRegisterDTO();
> HttpSession session = request.getSession();
> User u = (User) session.getAttribute("user");
> userDataDTO.setId(u.getUserId());
> userDataDTO.setFullname(u.getFullname());
> ...
>return userDataDTO;
> }
>
> and struts-config file:
> path="/Register2"
> type="cz.chalu.struts.modules.completeregister.LoadDataAction"
> parameter=".main.registerFinish"/>
>
> But there is some mistake.
> What is the correct way to do it?
>
> Thanks, Jiri
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]