Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cocoon.forms.validation.impl
Class JavaScriptValidator

    java.lang.Object
      org.apache.cocoon.forms.validation.impl.JavaScriptValidator

All Implemented Interfaces:
  WidgetValidator

public class JavaScriptValidator
extends Object
implements WidgetValidator

A `WidgetValidator` implemented as a JavaScript snippet.

This snippet must return a value which can be of different types. The only way to indicate successfull validation is to return a boolean `true` value.

To indicate validation error, a number of result types are possible:

- A boolean `false`: the validator must then have set a validation error on the validated widget or one of its children.
- A `ValidationError`: this error is then set on the validated widget.
- A `String`: a validation error using that string as a non-i18nized message is then set on the validated widget
- An `XMLizable` such as `I18nMessage`: this xmlizable is used to build a validation error that is set on the validated widget.

The JavaScript snippet has the "this" and "widget" variables set to the validated widget, and, if the form is used in a flowscript, can use the flow's global values and fonctions and the `cocoon` object.

Version:
  $Id: JavaScriptValidator.java 587759 2007-10-24 03:00:37Z vgritsenko $

Constructor Summary
`JavaScriptValidator(org.apache.cocoon.processing.ProcessInfoProvider processInfoProvider, org.mozilla.javascript.Function function)`

Method Summary
`boolean` | `validate(Widget widget)` Validate a widget.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JavaScriptValidator

    public JavaScriptValidator(org.apache.cocoon.processing.ProcessInfoProvider processInfoProvider,
                               org.mozilla.javascript.Function function)

Method Detail

### validate

    public final boolean validate(Widget widget)

  Description copied from interface: `WidgetValidator`
  Validate a widget.

  Specified by:
    `validate` in interface `WidgetValidator`
  Parameters:
    `widget` - the widget to validate
  Returns:
    `true` if validation was successful. If not, the validator must have set a `ValidationError` on the widget or one of its children.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1999-2008 The Apache Software Foundation. All Rights Reserved.