org.apache.shale.validator.util
Class AbstractUtilities

java.lang.Object
  extended by org.apache.shale.validator.util.AbstractUtilities
All Implemented Interfaces:
javax.faces.component.StateHolder
Direct Known Subclasses:
AbstractConverter, AbstractValidator

public abstract class AbstractUtilities
extends Object
implements javax.faces.component.StateHolder

Abstract base class for converters and validators that use Apache Commons Validator as their foundation. This class provides common utility methods for concrete converter and validator implementations.


Field Summary
static String DEFAULT_RESOURCE_BUNDLE
          Name of the resource bundle containing default message strings.
 
Constructor Summary
AbstractUtilities()
           
 
Method Summary
 String getMessage()
          Return the custom error message template for this converter or validator, if any.
 boolean isTransient()
          
protected  String message(javax.faces.context.FacesContext context, String key)
          Return a locale-sensitive message for this converter or validator.
protected  String message(javax.faces.context.FacesContext context, String key, Object[] parameters)
          Retrieve a locale-specific message for the specified key, then treat it as a message format pattern, and substitute in the specified parameter values and return the resulting string.
protected  String message(Locale locale, String message, Object[] parameters)
          Use the specified message as a message format pattern, substitute in the specified parameter values, and return the resulting string.
 void restoreState(javax.faces.context.FacesContext context, Object state)
          
 Object saveState(javax.faces.context.FacesContext context)
          
 void setMessage(String message)
          Set the custom error message template for this validator.
 void setTransient(boolean transientValue)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_RESOURCE_BUNDLE

public static final String DEFAULT_RESOURCE_BUNDLE

Name of the resource bundle containing default message strings.

See Also:
Constant Field Values
Constructor Detail

AbstractUtilities

public AbstractUtilities()
Method Detail

getMessage

public String getMessage()

Return the custom error message template for this converter or validator, if any. If not defined, a standard error message template will be used instead.


setMessage

public void setMessage(String message)

Set the custom error message template for this validator.

Parameters:
message - The new custom error message template, or null to select the standard template

restoreState

public void restoreState(javax.faces.context.FacesContext context,
                         Object state)

Specified by:
restoreState in interface javax.faces.component.StateHolder

saveState

public Object saveState(javax.faces.context.FacesContext context)

Specified by:
saveState in interface javax.faces.component.StateHolder

isTransient

public boolean isTransient()

Specified by:
isTransient in interface javax.faces.component.StateHolder

setTransient

public void setTransient(boolean transientValue)

Specified by:
setTransient in interface javax.faces.component.StateHolder

message

protected String message(javax.faces.context.FacesContext context,
                         String key)

Return a locale-sensitive message for this converter or validator. The following algorithm is applied to select the appropriate message:

Parameters:
context - FaceContext for the current request
key - Message key for the requested message

message

protected String message(javax.faces.context.FacesContext context,
                         String key,
                         Object[] parameters)

Retrieve a locale-specific message for the specified key, then treat it as a message format pattern, and substitute in the specified parameter values and return the resulting string.

Parameters:
context - FaceContext for the current request
key - Message key for the requested message
parameters - Replacement parameters to substitute in to the retrieved message

message

protected String message(Locale locale,
                         String message,
                         Object[] parameters)

Use the specified message as a message format pattern, substitute in the specified parameter values, and return the resulting string.

Parameters:
locale - Locale for performing parameter replacement
message - Message format pattern string
parameters - Replacement parameters to substitute in to the message format pattern


Copyright © 2004-2007 Apache Software Foundation. All Rights Reserved.