org.kuali.rice.krad.uif.util
Class ClientValidationUtils

java.lang.Object
  extended by org.kuali.rice.krad.uif.util.ClientValidationUtils

public class ClientValidationUtils
extends Object

This class contains all the methods necessary for generating the js required to perform validation client side. The processAndApplyConstraints(InputField field, View view) is the key method of this class used by InputField to setup its client side validation mechanisms.

Author:
Kuali Rice Team (rice.collab@kuali.org)

Nested Class Summary
static class ClientValidationUtils.ValidationMessageKeys
           
 
Field Summary
static String ALL_MSG_KEY
           
static String AND_MSG_KEY
           
static String ATMOST_MSG_KEY
           
static String GENERIC_FIELD_MSG_KEY
           
static String LABEL_KEY_SPLIT_PATTERN
           
static String MUSTOCCURS_MSG_KEY
           
static String OR_MSG_KEY
           
static String POSTREQ_MSG_KEY
           
static String PREREQ_MSG_KEY
           
 
Constructor Summary
ClientValidationUtils()
           
 
Method Summary
static void addScriptToPage(View view, InputField field, String script)
          Adds the script to the view to execute on a jQuery document ready event.
static String generateMessageFromLabelKey(List<String> params, String labelKey)
           
static String generateValidatorMessagesOption()
          Generates the js object used to override all default messages for validator jquery plugin with custom messages derived from the configService.
static String getRegexMethod(InputField field, ValidCharactersConstraint validCharactersConstraint)
          Returns the add method jquery validator call for the regular expression stored in validCharactersConstraint.
static String getRegexMethodWithBooleanCheck(InputField field, ValidCharactersConstraint validCharactersConstraint)
          Returns the add method jquery validator call for the regular expression stored in validCharactersConstraint that explicitly checks a boolean.
static void processAndApplyConstraints(InputField field, View view)
          This method processes all the constraints on the InputField passed in and adds all the necessary jQuery and js required (validator's rules, methods, and messages) to the View's onDocumentReady call.
static void processCaseConstraint(InputField field, View view, CaseConstraint constraint, String andedCase)
          This method processes a single CaseConstraint.
static void processMustOccurConstraint(InputField field, View view, MustOccurConstraint mc, String booleanStatement)
          This method processes the MustOccurConstraint.
static void processPrerequisiteConstraint(InputField field, PrerequisiteConstraint constraint, View view)
          This method is a simpler version of processPrerequisiteConstraint
static void processPrerequisiteConstraint(InputField field, PrerequisiteConstraint constraint, View view, String booleanStatement)
          This method processes a Prerequisite constraint that should be applied when the booleanStatement passed in evaluates to true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LABEL_KEY_SPLIT_PATTERN

public static final String LABEL_KEY_SPLIT_PATTERN
See Also:
Constant Field Values

PREREQ_MSG_KEY

public static final String PREREQ_MSG_KEY
See Also:
Constant Field Values

POSTREQ_MSG_KEY

public static final String POSTREQ_MSG_KEY
See Also:
Constant Field Values

MUSTOCCURS_MSG_KEY

public static final String MUSTOCCURS_MSG_KEY
See Also:
Constant Field Values

GENERIC_FIELD_MSG_KEY

public static final String GENERIC_FIELD_MSG_KEY
See Also:
Constant Field Values

ALL_MSG_KEY

public static final String ALL_MSG_KEY
See Also:
Constant Field Values

ATMOST_MSG_KEY

public static final String ATMOST_MSG_KEY
See Also:
Constant Field Values

AND_MSG_KEY

public static final String AND_MSG_KEY
See Also:
Constant Field Values

OR_MSG_KEY

public static final String OR_MSG_KEY
See Also:
Constant Field Values
Constructor Detail

ClientValidationUtils

public ClientValidationUtils()
Method Detail

generateMessageFromLabelKey

public static String generateMessageFromLabelKey(List<String> params,
                                                 String labelKey)

generateValidatorMessagesOption

public static String generateValidatorMessagesOption()
Generates the js object used to override all default messages for validator jquery plugin with custom messages derived from the configService.

Returns:

getRegexMethod

public static String getRegexMethod(InputField field,
                                    ValidCharactersConstraint validCharactersConstraint)
Returns the add method jquery validator call for the regular expression stored in validCharactersConstraint.

Parameters:
validCharactersConstraint -
Returns:
js validator.addMethod script

getRegexMethodWithBooleanCheck

public static String getRegexMethodWithBooleanCheck(InputField field,
                                                    ValidCharactersConstraint validCharactersConstraint)
Returns the add method jquery validator call for the regular expression stored in validCharactersConstraint that explicitly checks a boolean. Needed because one method accepts params and the other doesn't.

Parameters:
validCharactersConstraint -
Returns:
js validator.addMethod script

processCaseConstraint

public static void processCaseConstraint(InputField field,
                                         View view,
                                         CaseConstraint constraint,
                                         String andedCase)
This method processes a single CaseConstraint. Internally it makes calls to processWhenConstraint for each WhenConstraint that exists in this constraint. It adds a "dependsOn" css class to this field for the field which the CaseConstraint references.

Parameters:
view -
andedCase - the boolean logic to be anded when determining if this case is satisfied (used for nested CaseConstraints)

addScriptToPage

public static void addScriptToPage(View view,
                                   InputField field,
                                   String script)
Adds the script to the view to execute on a jQuery document ready event.

Parameters:
view -
script -

processPrerequisiteConstraint

public static void processPrerequisiteConstraint(InputField field,
                                                 PrerequisiteConstraint constraint,
                                                 View view)
This method is a simpler version of processPrerequisiteConstraint

Parameters:
constraint -
view -
See Also:
processPrerequisiteConstraint(org.kuali.rice.krad.uif.field.InputField, PrerequisiteConstraint, View, String)

processPrerequisiteConstraint

public static void processPrerequisiteConstraint(InputField field,
                                                 PrerequisiteConstraint constraint,
                                                 View view,
                                                 String booleanStatement)
This method processes a Prerequisite constraint that should be applied when the booleanStatement passed in evaluates to true.

Parameters:
constraint - prerequisiteConstraint
view -
booleanStatement - the booleanstatement in js - should return true when the validation rule should be applied

processMustOccurConstraint

public static void processMustOccurConstraint(InputField field,
                                              View view,
                                              MustOccurConstraint mc,
                                              String booleanStatement)
This method processes the MustOccurConstraint. The constraint is only applied when the booleanStatement evaluates to true during validation. This method creates the addMethod and add rule calls for the jquery validation plugin necessary for applying this constraint to this field.

Parameters:
view -
mc -
booleanStatement - the booleanstatement in js - should return true when the validation rule should be applied

processAndApplyConstraints

public static void processAndApplyConstraints(InputField field,
                                              View view)
This method processes all the constraints on the InputField passed in and adds all the necessary jQuery and js required (validator's rules, methods, and messages) to the View's onDocumentReady call. The result is js that will validate all the constraints contained on an InputField during user interaction with the field using the jQuery validation plugin and custom code.

Parameters:
field -


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.