|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object atg.droplet.TagConverterManager
public class TagConverterManager
This class contains a set of static methods which you can use to register and use TagConverters. TagConverters are used to perform String to Object and Object to String conversion in the valueof, input and param tags.
To add your own converter, follow these steps:
getNameReturns the name of your converter. This is the name that is used as an argument to the converter attribute in a tag. For example, if your getName method returned "currency", you'd define a tag like:
<valueof param="myPrice" converter="currency" >
getTagAttributeDescriptorsReturns the list of attribute arguments that this converter takes. These attributes are just listed along with the "converter" attribute in your valueof, input, or param tag. These attributes can mark themselves as optional if they are not required. For example, the currency converter above might take a locale attribute which is optional (the default behavior if this attribute is missing would be to use the locale associated with the current request).
A TagAttributeDescriptor also can mark itself as "automatic" which means that this attribute implies the use of this converter, even if the converter attribute is not specified. For example, if the currency converter defined a "currency" attribute that was automatic, you can use this converter in your page with:
<valueof param="myPrice" currency >
It is legal to define a TagConverter which takes the same attribute as another TagConverter as long as it is not ambiguous which converter to use for a given tag. The "required" attribute is an automatic attribute for the RequiredTagConverter. The DateTagConverter has "date" as an automatic attribute and "required" as an optional attribute. If you use both "date" and "required" in the same tag, the DateTagConverter is used. If you use just "required", the RequiredTagConverter is used.
convertStringToObjectThis method is called in two circumstances. If you are using an input tag, when that form value is submitted, this method is called before the setX method of your bean is called. It is the job of your convertStringToObject method to generate the Object value for use in the setX method. It can throw a TagConversionException if an error occurs during the conversion process. This method is also called if you use this converter with a param tag when the value of the parameter is defined.
convertObjectToStringThis method is called in two situations. When you use a converter in a valueof tag, this method is used to convert the Object value into a String value before displaying it. Also, when you use this tag in an input tag with a bean attribute and no existing value attribute, this method is called to fill in the value attribute with the current value of the bean property.
TagConverter
Field Summary | |
---|---|
static java.lang.String |
CLASS_VERSION
|
static java.lang.Object |
SET_AS_NULL
|
Constructor Summary | |
---|---|
TagConverterManager()
|
Method Summary | |
---|---|
static java.lang.Object |
convertStringToObject(TagConverter pCvt,
DynamoHttpServletRequest pReq,
java.lang.String pValue,
java.util.Properties pAttributes)
This method converts Strings to Objects swallowing the conversion exception so that it can be used in a class constructor. |
static TagConverter |
getTagConverterByAttribute(java.lang.String pAttributeName)
Returns the TagConverter registered for a specific attribute name. |
static TagConverter |
getTagConverterByName(java.lang.String pConverterName)
Returns the TagConverter for a specified set of attributes. |
static boolean |
isTagAttribute(TagConverter pCvt,
java.lang.String pAttributeName)
Returns true if this is an attribute (either required or optional) for this converter. |
static void |
registerTagConverter(TagConverter pConverter)
Adds a new TagConverter to the global list of converters. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String CLASS_VERSION
public static final java.lang.Object SET_AS_NULL
Constructor Detail |
---|
public TagConverterManager()
Method Detail |
---|
public static void registerTagConverter(TagConverter pConverter)
public static TagConverter getTagConverterByName(java.lang.String pConverterName)
public static TagConverter getTagConverterByAttribute(java.lang.String pAttributeName)
public static boolean isTagAttribute(TagConverter pCvt, java.lang.String pAttributeName)
public static java.lang.Object convertStringToObject(TagConverter pCvt, DynamoHttpServletRequest pReq, java.lang.String pValue, java.util.Properties pAttributes)
The pReq argument can be null if there is no request with which to implement the conversion. If you are using the request to access the locale with which to perform the conversion, use the default locale in this case.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |