I'd consider adding an error property to the bean that corresponded to
each item. 

In the validate() method, you could then set the error property for
whichever item was at fault (if any), using the same key you would use
for ActionError.

On the JSP side, you can use the message tag to translate the text. 

ActionError does the same thing in bulk, but you can use the same
technique on your own. 

-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services



Michael Marrotte wrote:
> 
> The ActionErrors work great for static pages.  But, the rows in my example
> are dynamic.  How do I name them in say an <logic:iterate> tag.  Or, better
> yet is there a straightforward or best-practice way to handle this with
> Struts?
> 
> Thanks,
> 
> Michael Marrotte
> 
> -----Original Message-----
> From: DHS Struts [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 17, 2002 7:33 AM
> To: [EMAIL PROTECTED]
> Subject: Re: How do you recommend doing this with Struts?
> 
> Read the JavaDocs on ActionError, ActionErrors, and the html:error tag. I
> think you'll find that you can position error messages next to the user
> value that is incorrect.
> 
> mark n.
> 
> >From: "Michael Marrotte" <[EMAIL PROTECTED]>
> >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>
> >Subject: How do you recommend doing this with Struts?
> >Date: Thu, 16 May 2002 17:29:22 -0400
> >
> >Say the following form (FORM A) -- maybe representative of a shopping
> >cart -- is generated dynamically:
> >
> >FORM A:
> >-------------------------
> >| item a | qty __  |
> >-------------------------
> >| item b | qty __  |
> >-------------------------
> >| ...                   |
> >-------------------------
> >| item n | qty __  |
> >-------------------------
> >
> >And, say the user submits the values "2,M, and 3" for items "a,b and n",
> >respectively.  Assuming "M" is an invalid "qty", the following form (FORM
> >A,
> >again with error messages) gets generated:
> >
> >FORM A:
> >ERROR:  Please fix errors marked, below.
> >-------------------------
> >| item a | qty  2  |
> >-------------------------
> >| item b | qty M  | ERROR: Invalid qty.
> >-------------------------
> >| ...                   |
> >-------------------------
> >| item n | qty  3  |
> >-------------------------
> >
> >How do you recommend doing this with Struts?  What class(es) should be
> >used?
> >How can errors be stored and retrieved dynamically?
> >
> >Thanks in advance,
> >
> >--Michael Marrotte
> 
> _________________________________________________________________
> Chat with friends online, try MSN Messenger: http://messenger.msn.com
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

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

Reply via email to