instead of the scriptlet, I think you could use html-el and do the following:

<html-el:messages id="error" property="orders[${ndx}].partNumber">
The el notation forces the ndx to evaluate

From: Bill Siggelkow <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Re: html:errors for indexed properties
Date: Tue, 31 Aug 2004 08:01:15 -0400

You have to use the html:messages tag in a loop to generate the property values in a loop.
Here's an example --


<logic:iterate name="IndexedListForm" property="orders"
id="orders" indexId="ndx">
<tr>
<td>
<html:text name="orders" property="partNumber" indexed="true"/><br />&nbsp;
<html:messages id="error" property='<%="orders["+ndx+"].partNumber"%>'>
<font color="red"><bean:write name="error"/></font>
</html:messages>
</td>
<td>
<html:text name="orders" property="quantity" indexed="true"/><br />&nbsp;
<html:messages id="error" property='<%="orders["+ndx+"].quantity"%>'>
<font color="red"><bean:write name="error"/></font>
</html:messages>
</td>
</tr>
</logic:iterate>



Enjoy!

Bill Siggelkow

Milind Rao wrote:
I have googled and searched the mailing list, but couldn't find an
answer to this.

I have a DynaValidatorForm containing a collection of objects
presented using the logic:iterate tag in the JSP.  The validation of
the objects in the collection is done in the validation.xml file using
something like

<field property="closeHour"
indexedListProperty= "regularTimingList"
depends="integer, intRange">
<arg0 key="error.workingHours.invalidHour" />
<arg1 name="intRange" key="${var:min}"
resource="false"/>
<arg2 name="intRange" key="${var:max}"
resource="false"/>
<var><var-name>min</var-name><var-value>0</var-value></var>
<var><var-name>max</var-name><var-value>24</var-value></var>
</field>


This creates an Action error for the property
regularTiming[i].closeHour.  'i' being the index  of the collection
that fails validation.

What do I use for the "property" element of the "html:errors" tag? I
hardcoded a property of "regularTimingList[1].closeHour" to see if the error shows up on the page if the close hour of the 2nd item in
the collection is invalid. It does. But obviously, I don't want to
do this for every record in the collection. What I need is an
equivalent of "logic:iterate" tag for errors. Any pointers to doing
this would be appreciated.




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




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



Reply via email to