anthony wrote:
change
Code:
<form-bean name="prescriptionForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="id" type="java.lang.String"/>
<form-property name="date" type="java.lang.String"/>
<form-property name="companyID" type="java.lang.Long"/>
</form-bean>
to
Code:
<form-bean name="prescriptionForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="pojo" type="com.jtemplate.vo.User"/> </form-bean>
then in your jsp / struts taglib you can hit pojo.id, pojo.date, pojo.company.xxx
I tried to do that, but there seems to be a problem with the data field and the DynaBean.
I could just do the following:
<form-property name="company" type="com.jtemplate.vo.Company"/>
and than in my taglib: company.xxx
But what I wanted to know is which strategy is the best for this kind of mappings. As mentioned I have a struts-form where I can input all the user fields (firstname, lastname, gender, ...) But I also have a combobox with all available companies. I have a select box:
<html:select property="companyID">
<html:options collection="companyCollection" property="id" labelProperty="name"/>
</html:select>
And when I submit the form, I need to retrieve the company object from the database (findCompanyByID) AGAIN and than I can link the user object to the retrieved company object. I think there must be better ways to do this kind of mapping?
Or is this THE way to do it?