Wednesday, February 3, 2010

Expression/Method Builder in Oracle JDeveloper 11g

In ADF Faces applications, you use Expression Language (EL) expressions to bind attributes to object values determined at runtime.

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 #{}.

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.
The context in which Expression Language is used can tell you whether the accessed resource is a property or a method. For example, the following access is to a property since the reference is from a component's value attribute:

  <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:


A managed bean can have the following standard JSF scopes: request, session, and application. In Oracle ADF, additional scopes are added:

  • pageFlow
  • view
  • backingBean
You access objects in those scopes (under the hood they're java.util.Map's) with scope qualification in the EL expression. For instance, to reference the MyBean managed bean from pageFlowScope scope, your expression would be #{pageFlowScope.MyBean}.

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
In Oracle ADF, the group of bindings supporting the UI components on a page are described in a page-specific XML file called the page definition file. The ADF Model layer uses this file at runtime to instantiate the page’s bindings. These bindings are held in a request-scoped map called the binding container, accessible during each page request using the EL expression:


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:


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. Expression Language in Oracle Fusion Developer Guide
  2. Creating ADF Data Binding EL Expressions
  3. Creating EL Expressions

1 comment:

Mike said...

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