org.springframework.binding.form.support
Class MessageSourceFieldFaceSource

java.lang.Object
  extended by org.springframework.binding.form.support.CachingFieldFaceSource
      extended by org.springframework.binding.form.support.MessageSourceFieldFaceSource
All Implemented Interfaces:
FieldFaceSource

public class MessageSourceFieldFaceSource
extends CachingFieldFaceSource

An implementation of FieldFaceSource that resolves the FieldFace from the MessageSourceAccessor provided to the setMessageSourceAccessor method or from the ApplicationServices singleton if none is provided.

The various properties of the FieldFace are resolved from a message source using message codes. These codes where generated by a MessageCodeStrategy. If no other MessageCodeStrategy is defined an instance of DefaultMessageCodeStrategy will be used

Author:
Oliver Hutchison, Mathias Broekelmann

Constructor Summary
MessageSourceFieldFaceSource()
          Constructs a new MessageSourcePropertyFaceDescriptorSource.
 
Method Summary
protected  IconSource getIconSource()
           
protected  String getMessage(String contextId, String fieldPath, String[] faceDescriptorProperty)
          Returns the value of the required property of the FieldFace.
protected  String getMessage(String contextId, String fieldPath, String[] faceDescriptorProperties, String defaultValue)
          Returns the value of the required property of the FieldFace.
protected  String[] getMessageKeys(String contextId, String fieldPath, String[] faceDescriptorProperties)
          Returns an array of message keys that are used to resolve the required property of the FieldFace.
 MessageCodeStrategy getMessageKeyStrategy()
           
protected  MessageSourceAccessor getMessageSourceAccessor()
          If a message source was provided to the setMessageSourceAccessor method returns that otherwise returns the default message source located using the ApplicationServices singleton
protected  FieldFace loadFieldFace(String field, Object context)
          Loads the FieldFace for the given field path and context id.
protected  FieldFace loadFieldFace(String field, String contextId)
           
 void setIconSource(IconSource iconSource)
          Set the icon source that will be used to resolve the FieldFace's icon property.
 void setMessageKeyStrategy(MessageCodeStrategy messageKeyStrategy)
           
 void setMessageSourceAccessor(MessageSourceAccessor messageSourceAccessor)
          Set the message source that will be used to resolve the FieldFace's properties.
 
Methods inherited from class org.springframework.binding.form.support.CachingFieldFaceSource
getFieldFace, getFieldFace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageSourceFieldFaceSource

public MessageSourceFieldFaceSource()
Constructs a new MessageSourcePropertyFaceDescriptorSource.

Method Detail

setMessageSourceAccessor

public void setMessageSourceAccessor(MessageSourceAccessor messageSourceAccessor)
Set the message source that will be used to resolve the FieldFace's properties.


getMessageSourceAccessor

protected MessageSourceAccessor getMessageSourceAccessor()
If a message source was provided to the setMessageSourceAccessor method returns that otherwise returns the default message source located using the ApplicationServices singleton


setIconSource

public void setIconSource(IconSource iconSource)
Set the icon source that will be used to resolve the FieldFace's icon property.


getIconSource

protected IconSource getIconSource()

getMessage

protected String getMessage(String contextId,
                            String fieldPath,
                            String[] faceDescriptorProperty)
Returns the value of the required property of the FieldFace. Delegates to the getMessageKeys for the message key generation strategy. This method uses [contextId + "." + ] fieldPath [ + "." + faceDescriptorProperty[0]] for the default value


getMessage

protected String getMessage(String contextId,
                            String fieldPath,
                            String[] faceDescriptorProperties,
                            String defaultValue)
Returns the value of the required property of the FieldFace. Delegates to the getMessageKeys for the message key generation strategy.


getMessageKeys

protected String[] getMessageKeys(String contextId,
                                  String fieldPath,
                                  String[] faceDescriptorProperties)
Returns an array of message keys that are used to resolve the required property of the FieldFace. The property will be resolved from the message source using the returned message keys in order.

Subclasses my override this method to provide an alternative to the default message key generation strategy.


loadFieldFace

protected FieldFace loadFieldFace(String field,
                                  String contextId)

loadFieldFace

protected FieldFace loadFieldFace(String field,
                                  Object context)
Description copied from class: CachingFieldFaceSource
Loads the FieldFace for the given field path and context id. This value will be cached so performance need not be a concern of this method.

Specified by:
loadFieldFace in class CachingFieldFaceSource
Parameters:
field - the form field path
context - optional context for which the FieldFace is being resolved
Returns:
the FieldFace for the given context id (never null).

getMessageKeyStrategy

public MessageCodeStrategy getMessageKeyStrategy()

setMessageKeyStrategy

public void setMessageKeyStrategy(MessageCodeStrategy messageKeyStrategy)


Copyright © 2004-2008 The Spring Framework. All Rights Reserved.