|
Record all objects that are exposed to the view. This involves their name or handle, as used across the view tier, and the class they represent.
For JSF, the objects exposed to the view are defined in faces-config.xml file. Some of these fall into the following groups.
- managed-bean
- message-bundle
- validator
- converter
Irrespective of the kind of object, the most important information are the define-id and define-class, the rest of the attributes when applicable; the session attribute has default.
BEHAVIOR DESCRIPTORS |
id |
type |
data-source |
value |
define-id |
define-class |
define-scope |
details |
| customerOrderBean |
define |
|
|
customerOrderBean |
com.example.CustomerOrder. |
session |
|
Despite the categories of objects that could be exposed to the view, as listed above, there is nothing specific that distinguishes their entries explicitly within the behavior descriptor. However, they would differ in nature, in the way that could not be mistaken.
| managed-bean | The "managed-bean" element represents a JavaBean. Unlike some other platform, there is no required interface or base class. Although any interface could be in use, it is inconceivable that any of those listed below, in this column, would be relevant. |
| validator | Must subscribe to interface javax.faces.validator.Validator |
| converter | Must subscribe to interface javax.faces.validator.Converter |
Although, as shown above, these groups of classes are distinguishable, it is common practice to use naming convention that distinguishes them. For instance, validators could always have the type included in the names, like FormatValidator.
Managed Bean
The information needed for this declaration is easy to map from the descriptor, as shown below.
For the declarative backing bean definition, the following attributes are employed.
| Attribute | Example | config. entry |
| id | Any unique identifier used purely for referencing the definition on the page. |
| define-id | customerOrderBean | <managed-bean-name> |
| define-class | com.example.CustomerOrder | <managed-bean-class> |
| define-scope | session | <managed-bean-scope> |
| details | description | <managed-bean-description> |
The corresponding entry in the JSF configuration file would be as follows:
<managed-bean>
<managed-bean-name>customerOrderBean</managed-bean-name>
<managed-bean-class>com.example.CustomerOrder</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
Resource Bundle
Another object exposed to the view is the resource bundle, used for displaying messages that could be internationalized. On the JSF, these are indistinguishable from regular objects, since the same object.property (bundle.key) is used to retrieve their contents. This actually restricts the naming convention that could be used for the key. Inclusion of additional period would be misunderstood; as the normal use is for nested objects.
| id | Any unique identifier used as the definition reference on the page |
| define-id | bundle | var |
| define-class | LocalizationResource | basename |
| define-scope | | N/A |
| detail | | Resource Bundle |
The implementation entry is on the view page; which makes sense since it only related to the page. Example is shown below.
<f:loadbundle basename="LocalizationResource" var="bundle"/>
Validator
| id | Any unique identifier used as the definition reference on the page |
| define-id | FormatValidator | <validator-id> |
| define-class | com.example.FormatValidator | <validator-class> |
| define-scope | | N/A |
| details | description | <managed-bean-description> |
The corresponding entry in the JSF configuration file would be as follows:
<validator>
<validator-id>FormatValidator</validator-id>
<validator-class>com.example.FormatValidator</validator-class>
</validator>
Converter
| id | Any unique identifier used as the definition reference on the page |
| define-id | creditCardConverter | <converter-id> |
| define-class | com.example.CreditCardConverter | <converter-class> |
| define-scope | | N/A |
| details | description | <managed-bean-description> |
The corresponding entry in the JSF configuration file would be as follows:
<converter>
<converter-id>creditCardConverter</Converter-id>
<converter-class>com.example.CreditCardConverter</Converter-class>
</converter>
More details are available in the attributes descriptions
type
id
data-source
value
define-id
define-class
define-scope
|