Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Description

WebWork The framework adds support for client-side validation on top of XWork's the standard validation framework.

Client-side validation It can be enabled on a per-form basis by specifying validate="true" in the form tag:.

A
Code Block
html
html

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

If a name for the form

...

is not given, the action mapping name will be used as the form name.

...

A Otherwise, a correct action and namespace attributes must be provided to the <ww <saf:form> tag. For example, the Action named

Code Block
html
html
titleReferencing "submitProfile"

...

in the "/user" namespace

...

<s
Code Block
htmlhtml

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

While the following will "work" in the sense that the form will function correctlyTechnically, the form's action attribute can refer to a "path" that includes the namespace and action as a URI. But, client-side validation will not: requires that the action name and namespeact to be set separately.

Code Block
html
html
titleWon't work with client-side validation!
<s
<ww:form action="/user/submitProfile.action" validate="true">
  ...
</wws:form>

All the standard usual validation configuration steps still apply to client-side validation. 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.

Note

(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
titleThe left hand doesn't know ...

The

Note

(info) Note that the required attribute on many WebWork Tags has nothing to do Struts Tags is not integrated with client-side validation. It is just ! The tag attribute is used by certain theme themes (like xhtml) to put a visual marker (usually '*' on the field marked as required.

Building a Validator that supports client-side validation

...

) next to the field. The tag doesn't know if the validation system actually "requires" the field or not.

Client Side Validation Types

There are two styles of client side validation.