You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Drago Jenko <dj...@zav-triglav.si> on 2003/04/24 16:29:04 UTC

example of indexed input fields with validation

Has someone working with table of input field and can show me an example, how to  validate indexed fields? I need to see validator.xml , form or DynaForm class ( or struts-config) and JSP file. 

Thanks
Drago Jenko



My classes look like  (see below) but I get an error ArrayIndexOutOfBoundsException from BeanUtils.getIndexedProperty:


 <form-bean name="bookForm" dynamic="true" type="org.apache.struts.validator.DynaValidatorForm">

<form-property name="cmd" type="java.lang.String"/>
<form-property name="books" type="xy.Book[]" />

</form-bean>

 And 

package xy;

 public class Book {

            private String book; 

            private String vso_osn_zav_vs; 

            private String book_price;

            private String idx;

On JSP  I have

<logic:iterate id="books" property="books" name="bookForm">

            <tr>

            <td class="TableField"><bean:write name="books" property="book"/></td>

            <td class="TableField"><bean:write name="books"  property="vso_osn_zav_vs"/></td>

            <td>

                <html:text name="books" property="book_price" indexed="true"  styleClass="FieldEntry" />

            </td>

            </tr>

</logic:iterate>

 in Validator.xml

<form name="bookForm">

    <field property="book_price" indexedListProperty="books" depends="integer">

            <arg0 key="common.rezer" />

    </field>


</form>