DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11050>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11050 No way to properly validate form properties of types other than String ------- Additional Comments From [EMAIL PROTECTED] 2002-07-22 20:39 ------- I understand what you are saying. My main intention was to reuse existing data beans as a nested properties of the form bean. For example, consider a User bean with "name", "password" and "age" properties. Age is numeric property. Now I can define a form bean, which will contain "user" property of type User. I can even easily define form as dynamic with dynamic "user" property: <form-bean name="createUserForm" type="org.apache.struts.validator.DynaValidatorForm" dynamic="true"> <form-property name="user" type="User"/> </form-bean> Now I can have the following in my JSP pages: ... <html:form action="/createuser"> <nested:nest property="user"> <table> <tr> <th><bean:message key="user.name"/></th> <td><nested:text property="name"/></td> </tr> <tr> <th><bean:message key="user.password"/></th> <td><nested:password property="password" redisplay="false"/></td> </tr> <tr> <th><bean:message key="user.age"/></th> <td><nested:text property="age"/></td> </tr> </table> </nested:nest> </html:form> ... and validation rules: <form-validation> <formset> <form name="createUserForm"> <field property="user.name" depends="required"> <arg0 key="user.name"/> </field> <field property="user.password" depends="required, minlength"> <arg0 key="user.password"/> <arg1 name="minlength" key="${var:minlength}" resource="false"/> <var> <var-name>minlength</var-name> <var-value>5</var-value> </var> </field> <field property="user.age" depends="required, integer"> <arg0 key="user.age"/> </field> <form name="createUserForm"> <formset> <form-validation> ... Everything works fine except age validation, like I described before. One of the reasons of resusing existing bean is that I can copy it back and forth between the form and buisness logic objects using PropertyUtils.copyProperties() or similar methods: public class CreateUserAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, WorkitemException { CreateUserCommand = new CreateUserCommand(); // business logic if (form != null) ActionHelpier.copyProperties(command, form); comand.execute(); ... } I could have used Strings for form bean properties, but struts tags will fail to resolve nested properties. For example, I could have defined my form bean as follows: <form-bean name="createUserForm" type="org.apache.struts.validator.DynaValidatorForm" dynamic="true"> <form-property name="user.name" type="java.lang.String"/> <form-property name="user.password" type="java.lang.String"/> <form-property name="user.age" type="java.lang.String"/> </form-bean> Form properties would be converted from String into native User bean property types, but I can't make struts tag libraries work with nested forms properties defined as above... -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>