Display an account expiration date in a user-friendly format based on separate month, day, and year fields. However, the date is stored in the database as a single physical attribute value in the format mm.dd.yyyy.
Create a logical attribute that associates the physical date attribute with three logical attributes that are displayed on the screen in separate Month, Day, and Year fields.
Note: Although the date in this use case is an expiration date, the custom logical attribute handler is a general date handler that can process any type of date.
To create a logical attribute for handling expiration dates and other dates
To obtain the names of the logical and physical attributes, you pass the values of the attribute Name field as defined in the Management Console to the getLogicalAttributeName() or getPhysicalAttributeName() method. These methods are in the LogicalAttributeContext object, which is passed into every call to DateFormatAdapter.
In this example, the attribute names you pass in are Month, Day, Year, and Date, as follows:
private final String LOGICAL_ATTRIBUTE_MONTH = "Month"; private final String LOGICAL_ATTRIBUTE_DAY = "Day"; private final String LOGICAL_ATTRIBUTE_YEAR = "Year"; private final String PHYSICAL_ATTRIBUTE_DATE = "Date"; . . . public void initialize(LogicalAttributeContext attrContext) throws Exception { String _month = attrContext.getLogicalAttributeName( LOGICAL_ATTRIBUTE_MONTH); String _day = attrContext.getLogicalAttributeName( LOGICAL_ATTRIBUTE_DAY); String _year = attrContext.getLogicalAttributeName( LOGICAL_ATTRIBUTE_YEAR); String _date = attrContext.getPhysicalAttributeName( PHYSICAL_ATTRIBUTE_DATE); . . . }
The handler uses the returned logical and physical attribute names when setting and retrieving attribute values.
It is not necessary to assign the corresponding physical attribute to a field on the task screen.
Copyright © 2013 CA.
All rights reserved.
|
|