You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Kawczynski, David" <da...@merck.com> on 2008/09/12 15:53:11 UTC

[S2] client-side validation error message duplication

I'm using struts 2.1.2, and the xhtml theme to render a form.
When client-side validaiton fails, an error message is placed above the
bad input fields.
Subsequent submission attempts result in new error messages being ADDED
to the UI, but the old messages are never removed.
I need to clear out previous submission attempt's error messages before
adding current submission attempt's error messages.
I appreciate any help you can provide!
-dave
Notice:  This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,
New Jersey, USA 08889), and/or its affiliates (which may be known
outside the United States as Merck Frosst, Merck Sharp & Dohme or
MSD and in Japan, as Banyu - direct contact information for affiliates is
available at http://www.merck.com/contact/contacts.html) that may be
confidential, proprietary copyrighted and/or legally privileged. It is
intended solely for the use of the individual or entity named on this
message. If you are not the intended recipient, and have received this
message in error, please notify us immediately by reply e-mail and
then delete it from your system.

Re: [S2] client-side validation error message duplication

Posted by Pascal Lalonde <pl...@auroramsc.com>.
If you are using Spring into your projet, this may be related to the 
beans being singletons, we had this problem in the past, we actually 
were required to call cleanErrorsAndMessages method at each prepare call.

- Pascal

Kawczynski, David wrote:
> I'm using struts 2.1.2, and the xhtml theme to render a form.
> When client-side validaiton fails, an error message is placed above the
> bad input fields.
> Subsequent submission attempts result in new error messages being ADDED
> to the UI, but the old messages are never removed.
> I need to clear out previous submission attempt's error messages before
> adding current submission attempt's error messages.
> I appreciate any help you can provide!
> -dave
> Notice:  This e-mail message, together with any attachments, contains
> information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,
> New Jersey, USA 08889), and/or its affiliates (which may be known
> outside the United States as Merck Frosst, Merck Sharp & Dohme or
> MSD and in Japan, as Banyu - direct contact information for affiliates is
> available at http://www.merck.com/contact/contacts.html) that may be
> confidential, proprietary copyrighted and/or legally privileged. It is
> intended solely for the use of the individual or entity named on this
> message. If you are not the intended recipient, and have received this
> message in error, please notify us immediately by reply e-mail and
> then delete it from your system.
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: [S2] client-side validation error message duplication

Posted by "Kawczynski, David" <da...@merck.com>.
--- On Fri, 9/12/08, Kawczynski, David wrote:
> I'm using struts 2.1.2, and the xhtml theme to render a
> form. When client-side validaiton fails, an error message
> is placed above the bad input fields.
> Subsequent submission attempts result in new error messages
> being ADDED to the UI, but the old messages are never removed.

I found the issue.  I was being a dodo.

The struts/xhtml/validation.js file's clearErrorMessages function
contains code to retrieve the table that stores the form.  It then
iterates over the table's rows, deleting any that has an "errorFor"
attribute.  In my case, the table that is retrieved is completely empty!
It turns out that my jsp file looks like this:

<s:form action="save">
	<table>
		<s:textfield blah blah blah/>
	</table>
</s:form>

Which resulted in the generated html to look like this:
<s:form action="save">
	<table class="wwFormTable">
		<table>
			<tr>
				<td blah blah blah</td>
			</tr>
		</table>
	</table>
</s:form>

The first table in the form had no rows!  Removing the empty <table>
elements from the jsp page fixed my issue.  I should pay more attention
when migrating from the simple theme to an xhtml theme.  :)

Notice:  This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,
New Jersey, USA 08889), and/or its affiliates (which may be known
outside the United States as Merck Frosst, Merck Sharp & Dohme or
MSD and in Japan, as Banyu - direct contact information for affiliates is
available at http://www.merck.com/contact/contacts.html) that may be
confidential, proprietary copyrighted and/or legally privileged. It is
intended solely for the use of the individual or entity named on this
message. If you are not the intended recipient, and have received this
message in error, please notify us immediately by reply e-mail and
then delete it from your system.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] client-side validation error message duplication

Posted by Dave Newton <ne...@yahoo.com>.
--- On Fri, 9/12/08, Kawczynski, David wrote:
> I'm using struts 2.1.2, and the xhtml theme to render a
> form. When client-side validaiton fails, an error message
> is placed above the bad input fields.
> Subsequent submission attempts result in new error messages
> being ADDED to the UI, but the old messages are never removed.

The label code is made of fairly brittle DOM manipulation; is there anything in your form that might mess with the DOM (IIRC there was an issue with hidden fields at one point; not sure if that was resolved or not)?

The code that does all that lives in validation.js, although it's not served from the template directory. If you want to customize yours you need to change the form-validate.ftl template to use the location of your copy of validation.js.

(I'm writing a small blurb about this in case my client-side validation changes don't meet with strenuous objections, but the technique is valid even if it doesn't make it in to the mainline release; I'll follow up when that's done.)

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org