Looks like you've got a few issues. Let me answer what I can and see if that
helps:

On 20050602 7:34 AM, "Nitesh" <[EMAIL PROTECTED]> wrote:

> 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.

If you make your form session scoped, you can drop the size attribute from
the 'userList' form-property. The Array will the size of the array you put
into the form in your Action.

> 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!)

This may be a situation where you cannot generate automatic client-side
validation and will have to either write it yourself, or just use server
side validation and represent the form if you have an error.

> 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.

In my experience, whenever I deal with Indexed properties, I've had to
create the actual Form class and put the validation into the validate (...)
method.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to