At runtime, the value of certain JSF UI components (such as an inputText component or an outputText component) is determined by its value attribute. While a component can have static text as its value, typically the value attribute will contain an EL expression that the runtime infrastructure evaluates to determine what data to display. For example, an outputText component that displays the name of the currently logged-in user might have its value attribute set to the expression #{UserInfo.name}.
In a typical JSF application, you would create objects like UserInfo as a managed bean. The JSF runtime manages instantiating these beans on demand when any EL expression references them for the first time. When displaying a value, the runtime evaluates the EL expression and pulls the value from the managed bean to populate the component with data when the page is displayed. If the user updates data in the UI component, the JSF runtime pushes the value back into the corresponding managed bean based on the same EL expression.
Value vs. Method Expression
EL expression can be:- Value expressions that can set as well as get data
- Method expressions which can invoke methods.
<af:inputtext label="Last Name" value="#{mybean.firstname}">
The access in the following is to a method since it is referenced from a listener attribute:
<af:inputtext label="Job" valuechangelistener="#{mybean.onValueChange}">
Expression Syntax
If an EL expression is used to access managed beans, it use the following synatx:#{<bean>.<method>}
A managed bean can have the following standard JSF scopes: request, session, and application. In Oracle ADF, additional scopes are added:
- pageFlow
- view
- backingBean
Oracle ADF Model implements the two concepts in JSR-227 that enable decoupling the user interface technology from the business service implementation:
- data controls
- declarative bindings
#{bindings}
This expression always evaluates to the binding container for the current page. For example, to access the collectionModel of binding object named MyShoppingCart , you use the EL expression:
#{bindings.MyShoppingCart.collectionModel}
Expression/Method Builder
As you see, EL expression can be used to access different kinds of runtime objects (i.e., managed bean, binding object, binding context, etc.) and its syntax can be convoluted with many levels. Fortunately, JDeveloper 11g has come to rescue on this. You can create EL expressions declaratively using either Expression Builder or Method Builder.To open the builder, select a JSF component in the JDeveloper visual edeitor or the Structure window and open the property inspector. In the JDeveloper property inspector, click the arrow icon next to the property field — for example, the HeaderText property — and choose Expression Builder or Method Builder. In the Builder dialog, you can browse and select the object to which the attribute will be bound.
The Builder in JDeveloper 11g exposes objects under the following categories as shown in the Figure:
- ADF Bindings — Contains references to the ADF binding layer of the current page and the ADF binding context, which exposes all configured binding definitions.
- ADF controller objects — ADF task flows extend the JSF navigation model and expose a ControllerContext object for EL access that allows developers to access information about the current displayed view, exceptions, the task flow URL for remote access, the train model, and much more.
- ADF managed beans — ADF managed beans are configured in the task flow configuration, not in the standard JSF faces-config.xml file. The node contains subnodes that represent the available scopes, making it easy to prefix the bean reference with the name of the scope in which it is defined.
- Faces' Resource Bundles — Allows access to resource bundle messages prepackaged with the application.
- JSF managed beans — Shows the managed beans that are defined in the faces-config.xml file, also categorized by the scopes in which they are defined.
- JSP objects — Allows access to the objects exposed by the JSF and servlet APIs. It exposes the FacesContext object and gives developers access to the servlet request header, cookies, servlet initialization parameters, and request parameters.
1 comment:
Your blog very helpful and clear, but I tried to refer to sample code but Unfortunately its not existed, please can provide us correct link for sample.
sap support pack stacks
Post a Comment