com.ibm.xsp.validator
Class DoubleRangeValidatorEx2

java.lang.Object
  extended by javax.faces.validator.DoubleRangeValidator
      extended by com.ibm.xsp.validator.DoubleRangeValidatorEx2
All Implemented Interfaces:
ComponentBindingObject, ValueBindingObject, ClientSideValidator, java.util.EventListener, javax.faces.component.StateHolder, javax.faces.validator.Validator

public class DoubleRangeValidatorEx2
extends javax.faces.validator.DoubleRangeValidator
implements ValueBindingObject, ComponentBindingObject, ClientSideValidator

Extends the standard double range validator to add support for automatic client-side validation and computed expressions on the properties. Corresponds to the xp:validateDoubleRange tag


Field Summary
static java.lang.String VALIDATOR_ID
           
 
Fields inherited from class javax.faces.validator.DoubleRangeValidator
MAXIMUM_MESSAGE_ID, MINIMUM_MESSAGE_ID, TYPE_MESSAGE_ID
 
Fields inherited from interface javax.faces.validator.Validator
NOT_IN_RANGE_MESSAGE_ID
 
Constructor Summary
DoubleRangeValidatorEx2()
           
 
Method Summary
 java.lang.String generateClientSideValidation(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Generate client side validation, a snippet of browser JavaScript in a single line, creating an instance of a Validator object matching the format described in xspClientDojo.js, the attachValidator function.
 javax.faces.component.UIComponent getComponent()
          Return the associated UIComponent instance.
protected  javax.faces.context.FacesContext getFacesContext()
           
 java.lang.String getInvalidMessage()
          Unlike server-side validators which display different error messages depending on the exact way that validation fails, client side validators usually have only one error message.
 double getMaximum()
           
 java.lang.String getMessage()
          Validation error message to be displayed to the user
 double getMinimum()
           
 javax.faces.el.ValueBinding getValueBinding(java.lang.String property)
          Return the ValueBinding instance to used to calculate the value for the specified property.
 void restoreState(javax.faces.context.FacesContext context, java.lang.Object state)
           
 java.lang.Object saveState(javax.faces.context.FacesContext context)
           
 void setComponent(javax.faces.component.UIComponent component)
          This will be called while constructing the component and the UIComponent tree, so no processing should be performed at this stage.
 void setMaximum(double maximum)
           
 void setMessage(java.lang.String message)
          Sets the validation error message to be displayed to the user
 void setMinimum(double minimum)
           
 void setValueBinding(java.lang.String property, javax.faces.el.ValueBinding binding)
          Set the ValueBinding instance to used to calculate the value for the specified property.
 void validate(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.Object value)
          Perform the correctness checks implemented by this Validator against the specified UIInput.
 
Methods inherited from class javax.faces.validator.DoubleRangeValidator
equals, isTransient, setTransient
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALIDATOR_ID

public static final java.lang.String VALIDATOR_ID
See Also:
Constant Field Values
Constructor Detail

DoubleRangeValidatorEx2

public DoubleRangeValidatorEx2()
Method Detail

validate

public void validate(javax.faces.context.FacesContext context,
                     javax.faces.component.UIComponent component,
                     java.lang.Object value)
              throws javax.faces.validator.ValidatorException

Perform the correctness checks implemented by this Validator against the specified UIInput. If any violations are found:

Specified by:
validate in interface javax.faces.validator.Validator
Overrides:
validate in class javax.faces.validator.DoubleRangeValidator
Parameters:
context - FacesContext for the request we are processing
component - UIInput we are checking for correctness
value -
Throws:
java.lang.NullPointerException - if context or component is null
javax.faces.validator.ValidatorException

setComponent

public void setComponent(javax.faces.component.UIComponent component)
Description copied from interface: ComponentBindingObject
This will be called while constructing the component and the UIComponent tree, so no processing should be performed at this stage.

Specified by:
setComponent in interface ComponentBindingObject
See Also:
ComponentBindingObject.setComponent(javax.faces.component.UIComponent)

getComponent

public javax.faces.component.UIComponent getComponent()
Description copied from interface: ComponentBindingObject
Return the associated UIComponent instance.

Specified by:
getComponent in interface ComponentBindingObject
Returns:
the associated UIComponent instance
See Also:
ComponentBindingObject.getComponent()

setMaximum

public void setMaximum(double maximum)
Overrides:
setMaximum in class javax.faces.validator.DoubleRangeValidator
See Also:
DoubleRangeValidator.setMaximum(double)

getMaximum

public double getMaximum()
Overrides:
getMaximum in class javax.faces.validator.DoubleRangeValidator

getFacesContext

protected javax.faces.context.FacesContext getFacesContext()

setMinimum

public void setMinimum(double minimum)
Overrides:
setMinimum in class javax.faces.validator.DoubleRangeValidator

getMinimum

public double getMinimum()
Overrides:
getMinimum in class javax.faces.validator.DoubleRangeValidator

getMessage

public java.lang.String getMessage()
Validation error message to be displayed to the user

Returns:
validation error message

getInvalidMessage

public java.lang.String getInvalidMessage()
Description copied from interface: ClientSideValidator
Unlike server-side validators which display different error messages depending on the exact way that validation fails, client side validators usually have only one error message. For example, you might have server-side messages "Value is less than minimum {0}" and "Value is greater than maximum {1}", but client-side you would only have one message "Value is not in the allowed range {0} to {1}".

This method may return different values depending on the configuration of the validator.

Specified by:
getInvalidMessage in interface ClientSideValidator
Returns:
message to display when the value is invalid.

setMessage

public void setMessage(java.lang.String message)
Sets the validation error message to be displayed to the user

Set the value of the message property.


getValueBinding

public javax.faces.el.ValueBinding getValueBinding(java.lang.String property)
Description copied from interface: ValueBindingObject
Return the ValueBinding instance to used to calculate the value for the specified property.

Specified by:
getValueBinding in interface ValueBindingObject
Parameters:
property - Name of the property
Returns:
ValueBinding instance to used to calculate the value for the specified property
See Also:
ValueBindingObject.getValueBinding(java.lang.String)

setValueBinding

public void setValueBinding(java.lang.String property,
                            javax.faces.el.ValueBinding binding)
Description copied from interface: ValueBindingObject
Set the ValueBinding instance to used to calculate the value for the specified property.

Specified by:
setValueBinding in interface ValueBindingObject
Parameters:
property - Name of the property
binding - The ValueBinding to set, or null to remove an existing ValueBinding
See Also:
ValueBindingObject.setValueBinding(java.lang.String, javax.faces.el.ValueBinding)

saveState

public java.lang.Object saveState(javax.faces.context.FacesContext context)
Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class javax.faces.validator.DoubleRangeValidator
See Also:
LengthValidator.saveState(javax.faces.context.FacesContext)

restoreState

public void restoreState(javax.faces.context.FacesContext context,
                         java.lang.Object state)
Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class javax.faces.validator.DoubleRangeValidator
See Also:
LengthValidator.restoreState(javax.faces.context.FacesContext, java.lang.Object)

generateClientSideValidation

public java.lang.String generateClientSideValidation(javax.faces.context.FacesContext context,
                                                     javax.faces.component.UIComponent component)
                                              throws java.io.IOException
Description copied from interface: ClientSideValidator
Generate client side validation, a snippet of browser JavaScript in a single line, creating an instance of a Validator object matching the format described in xspClientDojo.js, the attachValidator function.

The file xspClientDojo.js is reference in the source of every XPage. The version with comments is installed with Designer under the Data/domino/js folder, in a file named xspClientDojo.js.uncompressed.js.

The constructor of the Validator object should be passed any values needed to perform the validation (e.g. for a range validator the minimum and maximum values would be included). The translated error message to display if the error occurs should be passed to the validator too. Generally the server-side validators translate a default error message and allow the page designer to override the default in a "message" property.

Specified by:
generateClientSideValidation in interface ClientSideValidator
Parameters:
context - The current context.
component - The control whose value will be validated, usually a UIInput.
Returns:
snippet of browser JavaScript to create the Validator object.
Throws:
java.io.IOException