Your from bean definition is the most useful thing you can provide to answer this..


if in your formBean definition or in the actionForm class you've got type


<form-property name="myprop" type="com.whatever.ComplRegisterDTO" />

Then you're on the right lines.. But you're nesting so you jsp needs to be more like

ComplRegisterDTO myObj = whatever...

theForm.set("myprop",myObj);

.. or if you dig beanutils

BeanUtils.copyProperties(theForm, myObj) ; //a bit silly in the this case,

<html:text property="myprop.fullname" />

......Other wise if you've got (recommended).

<form-property name="fullname" type="java.lang.String" />
<form-property name="mail" type="java.lang.String" />


DynaACtionForm theForm = (DynaActionForm) form;


theForm.set("fullname","Joe Bloggs");
theForm.set("mail","[EMAIL PROTECTED]");

Does this help?

Cheers MArk



On Sunday, August 31, 2003, at 07:55 AM, Jiri Chaloupka wrote:

Hallo,
what is the correct way to load data from db into form?

I have some form:
<html:form action="/FinishRegister" method="post" focus="registerFull">
    <table border="0">
      <tr>
        <td><bean:message key="register.name.Fullname" />:</td>
        <td><html:text property="fullname" /></td>
      </tr>
      <tr>
        <td><bean:message key="register.name.Mail" />:</td>
        <td><html:text property="mail" /></td>
      </tr>
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:
<action
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]



Reply via email to