Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Validation Framework Classes

  • org.kuali.ricekfs.kns.util.ErrorMap
    Map that collects errors throughout a validation session. At each request, a new ErrorMap is added to
    GlobalVariables. Any method of the application can pull the ErrorMap out and add errors as needed:

    Code Block
    GlobalVariables.getMessageMap().put(propertyName,ErrorMap.ERROR_REQUIRED,propertyLabel)
    

    At the end of request processing, the ErrorMap is checked, and any errors are translated to ActionMessages for
    display in the jsp.

  • org.kuali.ricekfs.kns.exceptions.ValidationException
    Any exceptions encountered by the validation framework are wrapped in a ValidationException.
  • org.kuali.ricekfs.kns.service.(impl.)DictionaryValidationService(Impl) (junit org.kuali.ricekfs.kns.service.DictionaryValidationServiceTest)
    Provides entry points to validation against the data dictionary.
  • errors.tag
    Provides display of errors in the UI. The keyMatch attribute is a comma delimited string of error keys to match on. The tag
    performs a like on each against error keys in the map.

    Code Block
    <kul:errors keyMatch="document.sourceAccountingLines, newSourceLine"/>
    

    The above would display any errors whose key starts with document.sourceAccountingLines or newSourceLine (e.g.,
    document.sourceAccountingLines.account.accountNbr, newSourceLine.projectCode, ...)

...

  • When an error is encountered (e.g., in a Rule, or Business Object validation) add error to ErrorMap
  • GlobalVariables provides access to the ErrorMap for the request

    Code Block
    GlobalVariables.getMessageMap().put(RicePropertyConstantsKFSPropertyConstants.DOCUMENT+"."+RicePropertyConstantsKFSPropertyConstants.SOURCE_ACCOUNTING_LINE+"[" + accountingLineIndex + "]."+RiceProertyConstantsKFSPropertyConstants.ACCOUNT+"."+RicePropertyConstantsKFSPropertyConstants.ACCOUNT_NUMBER,ERROR_CONSTANTS.ERROR_NOT_VALID,accountNumber);
    
  • The first parameter to the ErrorMap is the fully qualified path to the field on the action form, less any prefix terms that have been added to the ErrorMap using the addToErrorPath method.

    Code Block
    GlobalVariables.getMessageMap().addToErrorPath(RicePropertyConstantsKFSPropertyConstants.DOCUMENT+"."+RicePropertyConstantsKFSPropertyConstants.SOURCE_ACCOUNTING_LINE+"[" + accountingLineIndex + "]");
    
    GlobalVariables.getMessageMap().put(RicePropertyConstantsKFSPropertyConstants.ACCOUNT+"."+RicePropertyConstantsKFSPropertyConstants.ACCOUNT_NUMBER,ERROR_CONSTANTS.ERROR_NOT_VALID,accountNumber);
     ....
    GlobalVariables.getMessageMap().removeFromErrorPath(RicePropertyConstantsKFSPropertyConstants.DOCUMENT+RicePropertyConstantsKFSPropertyConstants.SOURCE_ACCOUNTING_LINE+"[" + accountingLineIndex + "]");
    

    For information on other methods available to manipulate the ErrorMap and ErrorPath refer to the ErrorMap javadoc.

...