atg.droplet
Interface TagConverter

All Known Implementing Classes:
CreditCardTagConverter, CurrencyConversionTagConverter, CurrencyTagConverter, DateTagConverter, EscapeHTMLTagConverter, EuroTagConverter, NullableTagConverter, NumberTagConverter, RequiredTagConverter, ValueIsHTMLTagConverter

public interface TagConverter

This interface is implemented by objects that perform String to Object and Object to String conversion using attributes in JHTML tags (valueof, input, etc.). To add your own TagConverter (like the date, number, required, valueishtml converters), you write a class which implements this interface and then register that class with the TagConverterManager.

TagConverters play an important role in both validating and converting values submitted through HTML forms. They can also be used to flexibly format values of various types when converting object values such as dates, numbers, prices, etc. into values displayed to the user. The use of TagConverters can greatly improve the reuse and maintainability of your code and to avoid duplicating logic in each of your Java beans. It is useful to view TagConverters as playing the role of the controllers in the model/view/controller programming paradigm.

For more details on writing a converter @see atg.droplet.TagConverterManager.


Field Summary
static java.lang.String CLASS_VERSION
           
 
Method Summary
 java.lang.String convertObjectToString(DynamoHttpServletRequest pRequest, java.lang.Object pValue, java.util.Properties pAttributes)
          Converts the supplied Object value to a String value.
 java.lang.Object convertStringToObject(DynamoHttpServletRequest pRequest, java.lang.String pValue, java.util.Properties pAttributes)
          Converts the supplied String value to an Object value.
 java.lang.String getName()
          Returns the unique name for the TagConverter.
 TagAttributeDescriptor[] getTagAttributeDescriptors()
          Returns the list of TagAttributeDescriptors which are used by this converter.
 

Field Detail

CLASS_VERSION

static final java.lang.String CLASS_VERSION
See Also:
Constant Field Values
Method Detail

getName

java.lang.String getName()
Returns the unique name for the TagConverter. This name can be used by the TagConverterManager to get a handle to this converter. When you specify the use of a TagConverter using the converter attribute in a tag, you use this name to refer to the TagConverter. TagConverter names are case insensitive (as is the convention in HTML).


getTagAttributeDescriptors

TagAttributeDescriptor[] getTagAttributeDescriptors()
Returns the list of TagAttributeDescriptors which are used by this converter. Each TagAttributeDescriptor describes an attribute which can be used by this TagConverter. Attributes can be optional and they can also be automatic. An automatic attribute implies the use of this converter if that attribute appears in the tag (e.g. date=".." implies the use of the DateTagConverter).


convertStringToObject

java.lang.Object convertStringToObject(DynamoHttpServletRequest pRequest,
                                       java.lang.String pValue,
                                       java.util.Properties pAttributes)
                                       throws TagConversionException
Converts the supplied String value to an Object value. This operation is performed if a converter is used with an input tag during the form submission process or if a converter attributes are specified in the param tag when defining a new parameter.

Parameters:
pRequest - the request object for this conversion. This object can be null if the conversion is not performed in the context of a request.
pAttributes - The list of attributes in the tag that is invoking this converter.
pValue - The original String value to be converted.
Returns:
the converted object value.
Throws:
TagConversionException - if the conversion failed.

convertObjectToString

java.lang.String convertObjectToString(DynamoHttpServletRequest pRequest,
                                       java.lang.Object pValue,
                                       java.util.Properties pAttributes)
                                       throws TagConversionException
Converts the supplied Object value to a String value. This operation is performed when you are displaying a value using this converter. This occurs when the converter is used in the valueof tag or when rendering the value attribute of an input tag.

Parameters:
pRequest - the request this conversion applies to. You can use this request to obtain the RequestLocale to localize the conversion process. This can be null if the conversion is not performed in the context of a request.
pValue - the Object value to be converted to a String
pAttributes - the set of attributes supplied in this tag declaration.
Returns:
the converted object value.
Throws:
TagConversionException