org.milyn.validation
Interface OnFailResult


public interface OnFailResult

OnFail result.

Contains details of a validation rule failure.

Localized Messages

Every rule source file (no mater what the provider type) can have associated Validation message files (ResourceBundles).

The base bundle name is derived from the rules src. The Validation message base bundle name for a rules source "/a/b/c/rulesX.xml" would be "a/b/c/i18n/rulesX", which means that localized ResourceBundle files would need to be supplied on the classpath/filesystem as "/a/b/c/i18n/rulesX.properties", "/a/b/c/i18n/rulesX_en.properties", "/a/b/c/i18n/rulesX_de.properties" etc. The message property names are based on the rule property names e.g. the message bundle property name for rule "orderId" would also need to be "orderId".

The validation cartridge supports application of FreeMarker templates on the localized messages, allowing the messages to contain contextual data from the bean context, as well as data about the actual rule failure. FreeMarker based messages must be prefixed with "ftl:" and the contextual data is references using the normal FreeMarker notation. The beans from the bean context can be referenced directly, while the RuleEvalResult and rule failure path can be referenced through the "ruleResult" and "path" beans.

Example message using RegexProvider rules:

 customerId=ftl:Invalid customer number '${ruleResult.text}' at '${path}'.  Customer number must match pattern '${ruleResult.pattern}'.
 

Author:
tom.fennelly@jboss.com

Field Summary
static java.lang.String MAX_FAILS
          Maximum failures global param key.
 
Method Summary
 java.lang.String getFailFragmentPath()
          Get the path to the fragment on which the validation rule failure occured.
 RuleEvalResult getFailRuleResult()
          Get the validation failure RuleEvalResult.
 java.lang.String getMessage()
          Get a localized message for the validation failure.
 java.lang.String getMessage(java.util.Locale locale)
          Get a localized message for the validation failure.
 

Field Detail

MAX_FAILS

static final java.lang.String MAX_FAILS
Maximum failures global param key.

See Also:
Constant Field Values
Method Detail

getFailFragmentPath

java.lang.String getFailFragmentPath()
Get the path to the fragment on which the validation rule failure occured.

Returns:
The path to the fragment on which the validation rule failure occured.

getFailRuleResult

RuleEvalResult getFailRuleResult()
Get the validation failure RuleEvalResult.

Returns:
The validation failure RuleEvalResult.

getMessage

java.lang.String getMessage()
Get a localized message for the validation failure.

Uses the default Locale.

See Localized Messages.

Returns:
A localized message for the validation failure.

getMessage

java.lang.String getMessage(java.util.Locale locale)
Get a localized message for the validation failure.

See Localized Messages.

Returns:
A localized message for the validation failure.


Copyright © 2011. All Rights Reserved.