struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Taylor" <>
Subject Re: additional onsubmit javascript validation
Date Thu, 23 Sep 2010 11:48:03 GMT
Hi Dave,

Based on my requirements (leverage the existing Struts2 client-side 
validation framework),
I'm not sure modifying the templates will work here.

It appears that when validate="true" I need a way to tell Struts2 validation 
framework to not
populate the onsubmit attribute. But I still want it to generate the 
appropriate javascript based
on the field validations I have defined for the action. This way I could use 
my own onsubmit handler
to call the auto-generated javascript method (validatForm_MyAction()) at the 
appropriate time.
Reviewing the existing template files didn't reveal that this was possible 
by overriding a template.
Maybe I missed something.

----- Original Message ----- 
From: "Dave Newton" <>
To: "Struts Users Mailing List" <>
Sent: Wednesday, September 22, 2010 9:44 PM
Subject: Re: additional onsubmit javascript validation

>I modified the templates to allow pages to inject their own validation
> messages. Unfortunately I never checked this in. You could do it with a
> JavaScript framework, though, through binding.
> Dave
> On Wed, Sep 22, 2010 at 9:26 PM, Robert Taylor 
> <>wrote:
>> Greetings,
>> I'm using Struts2.2.1 and have a form using the xhtml theme which 
>> performs
>> some simple javascript validation (required, etc...).
>> Works great.
>> Now, after the simple javascript validation executes I would like to add
>> some more validation to the onsubmit event.
>> Apart from modifying a template, I couldn't see how this could be 
>> achieved
>> easily.
>> If you include the validation in the form onsubmit attribute, it is
>> prepended to the dynamically generated javascript validation function 
>> name.
>> For example:
>> <s:form action="MyAction" namespace="/mynamespace" theme="xhtml"
>> validate="true" onsubmit="return myValidation()">
>> produces the following markup.
>> <form id="Myaction"
>>         name="MyAction"
>>         onsubmit="return myValidation(); return validateForm_MyAction();"
>>         action="/scname/mynamespace/MyAction.html" method="post"
>>         onreset="clearErrorMessages(this);clearErrorLabels(this);">
>> As is evident, this won't work for me.
>> I want to leverage the dynamically generated Javascript validation when
>> validate="true". If that validation succeeds, then I want to execute some
>> proprietary validation.
>> I also know the name of the dynamically generated javascript method so I
>> could call it in myValidation();
>> Any suggestions would be appreciated.
>> Thanks,
>> /robert

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message