You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nitesh <ni...@cordiant.net> on 2005/06/02 12:58:30 UTC

Problem using indexed properties and validator framework

Hi,

I'm trying to use the validator framework with dyna forms.

In the JSP page I have a list of user details being listed for edit.

 <logic:iterate name="userList" id="userList" collection="<%= userListCol %>" type="com.sample.vo.UserDetails">
 <tr>
  <td><html:text property="userName" indexed="true" name="userList" /></td>
  <td><html:text property="userAddress" indexed="true" name="userList" /></td>
  <td><html:text property="userCountry" indexed="true" name="userList" /></td>
  <td><html:text property="userZipCode" indexed="true" name="userList" /></td>
  <td><html:text property="userEmail" indexed="true" name="userList" /></td>
  <td><html:text property="userPhone" indexed="true" name="userList" /></td>
 </tr>
 </logic:iterate>

I want this part to be validated on submit, and I intend to use validator framework with dynaforms.
My Struts config looks like...

  <form-bean name="UserListAdmin" type="org.apache.struts.action.DynaActionForm">
   <form-property name="userList" type="com.sample.vo.UserDetails[]" size="3" />
   <form-property name="test" type="java.lang.String" />
  </form-bean>



and my validation.xml looks like

  <form name="userListAdmin">
   <field property="test" depends="required">
    <arg0 key="label.test"></arg0>
   </field>
   <field property="userList" depends="required" indexedListProperty="userName">
    <arg0 key="label.username"></arg0>
   </field>
   <field property="userList" depends="required" indexedListProperty="userAddress">
    <arg0 key="label.address"></arg0>
   </field>
....
 </form>


The problems I face are:
1. When I try to use ArrayList instead of UserDetails[] for flexibility since I cannot predict the no of users in the list, I get ArrayIndexOutOfBounds exception.
2. The client side validation defined in the validation-rules is not generated for the indexed property. (Same page I have a non-indexed property and the client side validation is generated for this!)
3. By using UserDetails[], I do get the list in the Action class, but validation is not happening! (again problem only for the indexed property. works fine for the normal one.

Any help to resolve this would be great!


Thanks in Advance

Nitesh N