dWebSpec Dictionary
CONTEXT: descriptors->behavior-define




All Details Standard Only Platform Only
Structured Web info and helpTechnologies
 Home Page
 Product Page
 Download Page
 Feedback
Javascript Tree Menu

Results for:

 behavior-define 
Prev  Topic  Next

The definition of objects for use on the view tier is conceptually platform independent. A class is defined with a variable that provides access to its instance. Then there is a question of what scope the instance would live in.

The scopes are generally application, session, request and page, in the order of their width; application scope being the widest. This is however not universal. For component platforms that keep the page state, this would be kept across requests. Furthermore, there could be a conversation scope across multiple pages. Notwithstanding, the concepts here are relatively uniform across the platforms.

 JSF  

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-beanThe "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.
validatorMust subscribe to interface javax.faces.validator.Validator
converterMust 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.

AttributeExampleconfig. entry
idAny unique identifier used purely for referencing the definition on the page.
define-idcustomerOrderBean<managed-bean-name>
define-classcom.example.CustomerOrder<managed-bean-class>
define-scopesession<managed-bean-scope>
detailsdescription<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.

idAny unique identifier used as the definition reference on the page
define-idbundlevar
define-classLocalizationResource basename
define-scopeN/A
detailResource 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

idAny unique identifier used as the definition reference on the page
define-idFormatValidator<validator-id>
define-classcom.example.FormatValidator<validator-class>
define-scopeN/A
detailsdescription<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

idAny unique identifier used as the definition reference on the page
define-idcreditCardConverter<converter-id>
define-classcom.example.CreditCardConverter<converter-class>
define-scopeN/A
detailsdescription<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
Prev Next