You can create format masks that you set on the ADF Business Components attributes of entity objects and view objects to customize how the UI displays the value.
To map a formatter to a domain for use with Control Hints:
Create a new formatter class by extending the
oracle.jbo.format.Formatter
class.
Alternatively, you can customize one of the default formatters
provided in the oracle.jbo.format
package. The default
formatters provided with JDeveloper aggregate the formatters
provided in the java.text
package.
It is not necessary to create new domain to map a formatter. You may
use an existing domain when the business components project contains
a domain of the same data type as the formatter. For a list of
available default domain classes, see the <jdev_install
>/system/formatinfo.xml
file.
Edit the formatinfo.xml
file in the <
jdev_install>/system/
folder to map the formatter
class to a domain class. The XML definition of the formatter must
include a DOMAIN CLASS (which can be a new or existing one), the
FORMATTER, which includes the name and class, and the list of FORMAT
definitions the formatter class specifies.
To add a format mask to a formatter for use with Control Hints:
Edit the formatinfo.xml
file in the
JDeveloper/system/
folder to add the format mask to a
formatter. The XML definition of the format mask belongs to a
FORMATTER and a DOMAIN CLASS and includes the text specification of
the mask as it will appear in the Format
dropdown menu in the Control Hints panel of the Attribute Editor you
display for an attribute of the same type implemented by the
formatter.
To use the new formatter or format mask as a Control Hint:
Create a project for your Business Components.
In order to define control hints for your business components client application, you must have a project with entity objects and view objects.
The attribute you edit must be of the same type as the class implemented by the formatter or the new formatter will not be visible in the Format Type dropdown list.
Compile the Business Components project.
To format an attribute in your client application using the API:
The Control Hints API lets you format attribute values when the business components client do not automatically use the Format Type control hint. Typically, this includes Java UI clients. In that case, you need to:
Define the Control Hint for the attribute in the attribute editor.
Obtain the formatted attribute using the
getFormattedAttribute()
method on the attribute object:
import oracle.jbo.*; import java.util.Locale;
AttributeDef aDef = rs.getViewObject().findAttributeDef(sName); Row row = rs.getCurrentRow();
LocaleContext locale = rs.getApplicationModule().getSession().getLocaleContext();
if(aDef.getUIHelper().hasFormatInformation(locale))
obj = aDef.getUIHelper().getFormattedAttribute(row, locale);
Strip off the formatting from the attribute using the
parseFormattedAttribute()
method:
Display the attribute value:
if(aDef.getUIHelper().hasFormatInformation(locale))
Object value = aDef.getUIHelper().parseFormattedAttribute(sValue,
locale);
About Control Hints for Business Components Clients
Copyright © 1997, 2004, Oracle. All rights reserved.