|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.esri.adf.web.data.tasks.validator.GenericValidator
public class GenericValidator
GenericValidator is an implementation of the TaskParamValidator interface and helps to provide validation in the ADF Task framework. A Task contains parameters, actions, and tools. When a Task is rendered on a web page, the parameters are rendered as form fields to capture user input. Parameter values entered by the user can be validated using validators provided by the Task framework. The validators are java classes, but they emit javascript to perform validation on the browser using the DOJO Javascript library.
GenericValidator is an unstructed validator and is a super class of structured validators like
StringValidator
, DateValidator
, NumberValidator
, and NumberSpinner
. The structured
validators are specifically designed for their corresponding data type and provide validation rules relevant to the
data type. You should use structed validators wherever possible.
GenericValidator can be useful for validating data types not supported by the structured validators but available in the DOJO library. For example, the following code shows how to use the GenericValidator to validate a value representing currency :
TaskParamDescriptor paramDescriptor = ...; GenericValidator validator = new GenericValidator(); validator.addValidationRule(GenericValidator.ADFDOJOTYPE, "adfdijit.form.CurrencyTextBox"); validator.addValidationRule("constraints", "{fractional:true}"); validator.addValidationRule("currency", "USD"); validator.setPromptMessage("Enter price in USD."); paramDescriptor.setValidator(validator);
Field Summary | |
---|---|
static String |
ADFDOJOTYPE
Key used to stores the ADF Dojo Dijit type string, it is upon subclass implementing it. |
Constructor Summary | |
---|---|
GenericValidator()
|
Method Summary | |
---|---|
void |
addValidationRule(String key,
String value)
Validation rules are key-value pairs which are set as attributes on DOJO dijits to validate the parameter. |
String |
getInvalidMessage()
Returns the message that will be displayed to the user when the parameter's value does not pass the validation rules. |
String |
getPromptMessage()
Returns the message that will be displayed to the user when the parameter acquires focus on the web page. |
Properties |
getValidationRules()
Returns a |
boolean |
isRequired()
Specifies whether a value is mandatory for the parameter. |
void |
removeValidationRule(String key)
Removes the specified key if there is one exist in the validation rule. |
void |
setInvalidMessage(String invalidMessage)
Specifies the message that will be displayed to the user when the parameter's value does not pass the validation rules |
void |
setPromptMessage(String promptMessage)
Specifies the message that will be displayed to the user when the parameter acquires focus on the web page. |
void |
setRequired(boolean required)
Specifies whether a value is mandatory for the parameter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ADFDOJOTYPE
Constructor Detail |
---|
public GenericValidator()
Method Detail |
---|
public Properties getValidationRules()
getValidationRules
in interface TaskParamValidator
public void addValidationRule(String key, String value)
StringValidator
, DateValidator
, NumberValidator
, and
NumberSpinner
provide convenient methods to set validation rules. You will typically only use this method
when you want to set a validation rule not supported by those validators. Refer the DOJO documentation on
http://docs.dojocampus.org for more information on which attributes are supported by which dijits.
For example, the following code
GenericValidator validator = new GenericValidator(); validator.addValidationRule(GenericValidator.ADFDOJOTYPE, "adfdijit.form.CurrencyTextBox"); validator.addValidationRule("constraints", "{fractional:true}"); validator.addValidationRule("currency", "USD");renders the following HTML
<input type="TEXT" adfdojoType="adfdijit.form.CurrencyTextBox" constraints="{fractional:true}" currency="USD">
public void removeValidationRule(String key)
public String getInvalidMessage()
public void setInvalidMessage(String invalidMessage)
invalidMessage
- the message.public String getPromptMessage()
public void setPromptMessage(String promptMessage)
promptMessage
- the message.public boolean isRequired()
public void setRequired(boolean required)
required
- true, if the input value is mandatory.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |