You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 23 Next »

Description

WebWork adds support for client-side validation on top of XWork's standard validation framework. It can be enabled on a per-form basis by specifying validate="true" in the form tag:

<ww:form name="test" action="javascriptValidation" validate="true">
  ...
</ww:form>

A name for the form can be supplied, else the action name will be used as the form name.

A correct action and namespace attributes must be provided to the <ww:form> tag. For example, the Action named "submitProfile" is used in the "/user" namespace, the following must be used.

<ww:form namespace="/user" action="submitProfile" validate="true">
  ...
</ww:form>

While the following will "work" in the sense that the form will function correctly, client-side validation will not. That is because WebWork must know the exact namespace and action (rather than a URL) to properly support validation.

<ww:form action="/user/submitProfile.action" validate="true">
  ...
</ww:form>

All the standard validation configuration steps still apply. Client-side validation uses the same validation rules as server-side validation. If server-side validation doesn't work, then client-side validation won't work either.

(info) Not all validators support client-side validation. Currently only the followings validators supports client-side validation (xhtml theme).

  1. required validator
  2. requiredstring validator
  3. email validator
  4. url validator
  5. int validator

(info) Note that the required attribute on many WebWork Tags has nothing to do with client-side validation. It is just used by certain theme (like xhtml) to put a '*' on the field marked as required.

  • No labels