org.mentawai.rule
Class DependentFieldValueRule

java.lang.Object
  extended by org.mentawai.rule.DependentFieldValueRule
All Implemented Interfaces:
Rule

public class DependentFieldValueRule
extends Object
implements Rule

Make a field required only and only if another field is present in the form and its value be equals the especified.

Author:
Robert Willian Gil

Constructor Summary
protected DependentFieldValueRule(String field1, String field1Value, String field2)
           
 
Method Summary
 boolean check(String field, Action action)
          Check and validate the given field from the give action.
static DependentFieldValueRule getInstance(String field1, String field1Value, String field2)
           
 Map<String,String> getTokens()
          Returns a map with tokens that can be used in the error messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DependentFieldValueRule

protected DependentFieldValueRule(String field1,
                                  String field1Value,
                                  String field2)
Method Detail

getInstance

public static DependentFieldValueRule getInstance(String field1,
                                                  String field1Value,
                                                  String field2)
Parameters:
field1 - field that will be evaluated
field1Value - the value that will be compared with the value of first field
field2 - field that will be required if the value of field1 be equals specified in field1Value
Returns:
The rule

check

public boolean check(String field,
                     Action action)
Description copied from interface: Rule
Check and validate the given field from the give action.

Specified by:
check in interface Rule
Parameters:
field - The field to validate.
action - The action from where to get the field.
Returns:
true if the validation succeeds.

getTokens

public Map<String,String> getTokens()
Description copied from interface: Rule
Returns a map with tokens that can be used in the error messages. The tokens in the error messages will be replaced by the token values in this map.

Specified by:
getTokens in interface Rule
Returns:
A map with the token values.


Copyright © 2013. All Rights Reserved.