You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Howk, Michael" <MH...@FSC.Follett.com> on 2001/04/20 15:39:18 UTC

Making the Struts Validator work on the client side

I've finally got David Winterfeldt's Struts Validator working on the server
side, but it doesn't look like it's working on the client side. So I've got
a couple of questions:

First, how can I be sure whether or not the validator is working on the
client side? I'm assuming that, if the client side were working, my app
wouldn't call the server side validator at all.

Second, what am I missing? I've followed the example application (with the
tweaks required to get it to work on my environment). So far, I've added the
tag:
<validator:javascript formName="user.servlet.UserEditForm" page="1"/>
and the:
<html:form action="/user/servlet/handleusereditform.do" onsubmit="return
validateUserEditForm(this);">

The JSP runs fine, but it seems to skip over the client side validation. The
only thing I can think of is that my onsubmit property doesn't quite match
the formName property, because I need to put some of the package name in
front of the class name (that's how I entered it for the logic:xxx tags).
How do I know which function to use for the onsubmit property? Is that the
problem or am I missing something else? Or do I need to setup the
JavascriptValidatorTag somehow?

Thank you,
Michael Howk

Re: Making the Struts Validator work on the client side

Posted by David Winterfeldt <dw...@yahoo.com>.
--- "Howk, Michael" <MH...@FSC.Follett.com> wrote:
> I've finally got David Winterfeldt's Struts
> Validator working on the server
> side, but it doesn't look like it's working on the
> client side. So I've got
> a couple of questions:
> 
> First, how can I be sure whether or not the
> validator is working on the
> client side? I'm assuming that, if the client side
> were working, my app
> wouldn't call the server side validator at all.
It would still call the server side, but you wouldn't
notice it because all the validation would have
already been done on the client.

> 
> Second, what am I missing? I've followed the example
> application (with the
> tweaks required to get it to work on my
> environment). So far, I've added the
> tag:
> <validator:javascript
> formName="user.servlet.UserEditForm" page="1"/>
> and the:
> <html:form
> action="/user/servlet/handleusereditform.do"
> onsubmit="return
> validateUserEditForm(this);">
I auto-generate the Javascript method name so it would
actually create validateuser.servlet.UserEditForm for
the method name which isn't a legal method name.  I'll
make an optional attribute so you can specify the
method name.  It will be posted within an hour or two.
 The Javascript will also fail with nested properties
too.

> 
> The JSP runs fine, but it seems to skip over the
> client side validation. The
> only thing I can think of is that my onsubmit
> property doesn't quite match
> the formName property, because I need to put some of
> the package name in
> front of the class name (that's how I entered it for
> the logic:xxx tags).
> How do I know which function to use for the onsubmit
> property? Is that the
> problem or am I missing something else? Or do I need
> to setup the
> JavascriptValidatorTag somehow?
You can always look at the source sent to your browser
and see if it created the Javascript code where you
placed the JavascriptValidatorTag.  Then you can see
the name of the validation method that was generated.

> 
> Thank you,
> Michael Howk


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/