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]
Re: How do you recommend doing this with Struts?
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]
RE: How do you recommend doing this with Struts?
One way I thought of to do this is to store any errors in the bean that logic:iterate uses, e.g.: logic:iterate id=jspBean name=javaBean property=javaBeanProperty td item bean:write name=jspBean property=item/ /td td qty bean:write name=jspBean property=qty/ /td td bean:write name=jspBean property=inputErrors/ /td /logic:iterate But, here I'm using the inputErrors property of the javaBeanProperty of javaBean and I'm not using the html:error tag. Am I cheating or missing something in Struts that provides a consistent (more MVC) way to deal with this. What do you think of the above approach? Any thoughts are greatly appreciated? Thanks in advance, --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]
RE: How do you recommend doing this with Struts?
Thanks for your response... It's exactly what I was thinking and just posted a questiion about. Do you think this diverges from the MVC, though? Should validation errors ideally be stored in the Model? --Michael Marrotte -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED]] Sent: Friday, May 17, 2002 2:55 PM To: Struts Users Mailing List Subject: Re: How do you recommend doing this with Struts? 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] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: How do you recommend doing this with Struts?
The action:errors tag is a convenient interface to the Struts ApplicationResources. Any component in the application is welcome to use the ApplicationResources (hence the application moniker). What you might want to do is save the message key in the inputErrors property and then use bean:message to write it out. This will make it a drop-in replacement for action:errors. -- 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: One way I thought of to do this is to store any errors in the bean that logic:iterate uses, e.g.: logic:iterate id=jspBean name=javaBean property=javaBeanProperty td item bean:write name=jspBean property=item/ /td td qty bean:write name=jspBean property=qty/ /td td bean:write name=jspBean property=inputErrors/ /td /logic:iterate But, here I'm using the inputErrors property of the javaBeanProperty of javaBean and I'm not using the html:error tag. Am I cheating or missing something in Struts that provides a consistent (more MVC) way to deal with this. What do you think of the above approach? Any thoughts are greatly appreciated? Thanks in advance, --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]
Re: How do you recommend doing this with Struts?
Validation errors actually *belong* to the model, so yes. The error messages are coming out of the ApplicationResources. This is a standard Properties file and part of the standard approach to i18n in any Java application. Ideally, these should be shared with any other application that is doing the same sort of thing. Say something in Swing or JavaServer Faces. All content, including messages, really belong to the model. Conceptually, there's no difference between a paragraph of text and a memo field in the database. It's all model; it's all message. The view's job to format the content so that it can be displayed in the chosen medium. But the view does not own the content -- it owns the markup that surrounds the content. As a practical matter, we end up mixing static text into HTML and JSP files these days. But not because we ~want~ to. IMHO, the ActionForm is a controller component and not part of the view. It lives on the layer between the view and model, and so can be bound with either and both. -- 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: Thanks for your response... It's exactly what I was thinking and just posted a questiion about. Do you think this diverges from the MVC, though? Should validation errors ideally be stored in the Model? --Michael Marrotte -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED]] Sent: Friday, May 17, 2002 2:55 PM To: Struts Users Mailing List Subject: Re: How do you recommend doing this with Struts? 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] -- 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]
RE: How do you recommend doing this with Struts?
Works like a charm... Thanks for the input! --Michael Marrotte -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED]] Sent: Friday, May 17, 2002 3:38 PM To: Struts Users Mailing List Subject: Re: How do you recommend doing this with Struts? The action:errors tag is a convenient interface to the Struts ApplicationResources. Any component in the application is welcome to use the ApplicationResources (hence the application moniker). What you might want to do is save the message key in the inputErrors property and then use bean:message to write it out. This will make it a drop-in replacement for action:errors. -- 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: One way I thought of to do this is to store any errors in the bean that logic:iterate uses, e.g.: logic:iterate id=jspBean name=javaBean property=javaBeanProperty td item bean:write name=jspBean property=item/ /td td qty bean:write name=jspBean property=qty/ /td td bean:write name=jspBean property=inputErrors/ /td /logic:iterate But, here I'm using the inputErrors property of the javaBeanProperty of javaBean and I'm not using the html:error tag. Am I cheating or missing something in Struts that provides a consistent (more MVC) way to deal with this. What do you think of the above approach? Any thoughts are greatly appreciated? Thanks in advance, --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] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: How do you recommend doing this with Struts?
Isn't the message key mandatory for the bean:message, according to the TLD? So how can the key be set from a bean property? These other two approaches work. But, I don't think this is exaclty what you meant: 1.) bean:write name=jspBean property=inputError/ 2.) logic:equal name=jspBean property=inputError value=true bean:message key=error.qty/ /logic:equal How can I do this with bean:message? I want to write: bean:message name=jspBean property=inputError / But, I get the error about the mandatory key required. Thanks, --Michael Marrotte -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED]] Sent: Friday, May 17, 2002 3:38 PM To: Struts Users Mailing List Subject: Re: How do you recommend doing this with Struts? The action:errors tag is a convenient interface to the Struts ApplicationResources. Any component in the application is welcome to use the ApplicationResources (hence the application moniker). What you might want to do is save the message key in the inputErrors property and then use bean:message to write it out. This will make it a drop-in replacement for action:errors. -- 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: One way I thought of to do this is to store any errors in the bean that logic:iterate uses, e.g.: logic:iterate id=jspBean name=javaBean property=javaBeanProperty td item bean:write name=jspBean property=item/ /td td qty bean:write name=jspBean property=qty/ /td td bean:write name=jspBean property=inputErrors/ /td /logic:iterate But, here I'm using the inputErrors property of the javaBeanProperty of javaBean and I'm not using the html:error tag. Am I cheating or missing something in Struts that provides a consistent (more MVC) way to deal with this. What do you think of the above approach? Any thoughts are greatly appreciated? Thanks in advance, --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] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: How do you recommend doing this with Struts?
Ted, I got it working your way, i.e. with bean:message... But, I had to modify the TLD (struts-bean.tld). I modified the key attribute and added name and property attributes. attribute namekey/name requiredfalse/required rtexprvaluetrue/rtexprvalue /attribute attribute namename/name requiredfalse/required rtexprvaluetrue/rtexprvalue /attribute attribute nameproperty/name requiredfalse/required rtexprvaluetrue/rtexprvalue /attribute attribute Is it common practice to modify the TLD's for the Struts tags? --Micahel Marrotte -Original Message- From: Michael Marrotte [mailto:[EMAIL PROTECTED]] Sent: Friday, May 17, 2002 4:56 PM To: Struts Users Mailing List Subject: RE: How do you recommend doing this with Struts? Isn't the message key mandatory for the bean:message, according to the TLD? So how can the key be set from a bean property? These other two approaches work. But, I don't think this is exaclty what you meant: 1.) bean:write name=jspBean property=inputError/ 2.) logic:equal name=jspBean property=inputError value=true bean:message key=error.qty/ /logic:equal How can I do this with bean:message? I want to write: bean:message name=jspBean property=inputError / But, I get the error about the mandatory key required. Thanks, --Michael Marrotte -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED]] Sent: Friday, May 17, 2002 3:38 PM To: Struts Users Mailing List Subject: Re: How do you recommend doing this with Struts? The action:errors tag is a convenient interface to the Struts ApplicationResources. Any component in the application is welcome to use the ApplicationResources (hence the application moniker). What you might want to do is save the message key in the inputErrors property and then use bean:message to write it out. This will make it a drop-in replacement for action:errors. -- 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: One way I thought of to do this is to store any errors in the bean that logic:iterate uses, e.g.: logic:iterate id=jspBean name=javaBean property=javaBeanProperty td item bean:write name=jspBean property=item/ /td td qty bean:write name=jspBean property=qty/ /td td bean:write name=jspBean property=inputErrors/ /td /logic:iterate But, here I'm using the inputErrors property of the javaBeanProperty of javaBean and I'm not using the html:error tag. Am I cheating or missing something in Struts that provides a consistent (more MVC) way to deal with this. What do you think of the above approach? Any thoughts are greatly appreciated? Thanks in advance, --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
RE: How do you recommend doing this with Struts?
Suppose the qty values were HTML select's. How would you recommend I reset there values on error, e.g. 2,M,3, below is shown in the second form. Any help is greatly appreciated. Thanks, --Michael Marrotte -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED]] Sent: Friday, May 17, 2002 2:55 PM To: Struts Users Mailing List Subject: Re: How do you recommend doing this with Struts? 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] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
How do you recommend doing this with Struts?
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