Search This Blog

Wednesday, August 22, 2012

Different ways of getting Handle to AM from Backing Bean

Method 1 : (Note : ValueBinding is deprecated in 11g)
// 1. Create a value binding
// 2. Access the binding container
// 3. Find the data control using #data binding.
// 4. Access the data control's application module data provider

ValueBinding vb=fctx.getApplication().createValueBinding();
BindingContext bc = (BindingContext)vb.getValue(fctx);
DCDataControl dc =  bc.findDataControl("#{data}");
ApplicationModule am =(ApplicationModule)dc.getDataProvider();

Method 2 : (Typically used in a managed bean)
Configuration.createRootApplicationModule(MyAMDefn,AMConfig);
Configuration.releaseRootApplicationModule(,..);

Method 3 : (Typically used in a backing bean based on page iterators)
// 1. Access the binding container
// 2. Find a named iterator binding
// 3. Get the data control from the iterator binding
// 4. Access the data control's application module data provider

DCBindingContainer bc = (DCBindingContainer)getBindings();
DCIteratorBinding iter = bc.findIteratorBinding("MyVOIterator");
DCDataControl dc  = iter.getDataControl();
ApplicationModule am = (ApplicationModule)dc.getDataProvider();

Method 4 : (Typically used in a backing bean based on action binding)
// 1. Access the binding container
// 2. Find a named action binding
// 3. Get the data control from the iterator binding (or method binding)
// 4. Access the data control's application module data provider

DCBindingContainer bc = (DCBindingContainer)getBindings();
JUCtrlActionBinding action = (JUCtrlActionBinding)bc.findCtrlBinding("MyActionMethod");
DCDataControl dc = action.getDataControl();
ApplicationModule am = (ApplicationModule)dc.getDataProvider();

Method 5 :
// 1. Access the binding context
// 2. Find data control by name
// 3. Access the data control's application module data provider
FacesContext fctx = FacesContext.getCurrentInstance();
BindingContext bindingContext = BindingContext.getCurrent();
DCDataControl dc = bindingContext.findDataControl("MyModuleDataControl");
MyAMImpl am = (MyAMImpl)dc.getDataProvider();

Method 6 :
//Using Value Expression.
FacesContext fc = FacesContext.getCurrentInstance();
Application app = fc.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = fc.getELContext();
ValueExpression valueExp =elFactory.createValueExpression(elContext, "#{data.MyDataControl.dataProvider}",Object.class);
MyAMImpl am = (AmImpl)valueExp.getValue(elContext);

Saturday, August 18, 2012

Alternate approach for multiple row select on an ADF table

Earlier post covered a similar topic of how to capture multiple row selection made in an ADF table.

The problem with the earlier approach is that user have to select a row and in order to select the second row and subsequently from there on, they have to hold the ctrl key and click on the row to select additinal rows.

Here in this post, I am going to detail on an alternate approach which would eventually provide access to the selected row but with more user adaptablility.

Select the VO (say "MyVO") that you plan to create a ADF table, add an additional column as "selectMany" as an transient variable. Make sure to check the attribute updatable always.

When we drag the VO to create an ADF table make sure to change the new transient variable type from outputtext to selectBoolenCheckBox.
(OR)
Update the Edit Attribute : select Many control hints -> Control Type to Boolean.

Make sure the value on the checkbox looks something like this value="#{row.bindings.selectMany.inputValue}"

FacesContext facesContext = FacesContext.getCurrentInstance();
DCBindingContainer bindings = (DCBindingContainer)getBindings();
DCIteratorBinding iter = bindings.findIteratorBinding("MyVO");
RowSetIterator rsi = iter.getViewObject().createRowSetIterator(null);

Row current;
while (rsi.hasNext()) {
         current = rsi.next();
         if (true == current.getAttribute("selectMany")) {
                 // this is the row that is selected in the UI.
         }
}  

Friday, August 17, 2012

Fetch all the rows selected from a UI Table in ADF

Following is an example to get all the rows selected from a UI table in ADF.

How do we enable multiple selections on a table ?

When you drag and drop a VO on to a page, user is presented with different options to represent the data from the VO. Choose the option of ADF table and select the option of "multiple rows" under "Row Selection" (Other options available are None, Single row)

If there is no backing bean or Managed bean enabled while creating the page then create binding for the table, how ?
-------------------------------------------------------------------------
Click on the table in the structure panel, Go to property inspector - > Advance -> Binding - > Choose Edit -> Create new managed bean & create new porperty as "table1".

Above action creates a getter  and setter method for the "table1" as below in the bean.

    private RichTable table1;
   
    public void setTable1(RichTable table) {
        this.table = table;
    }

    public RichTable getTable1() {
        return table;
    }

-------------------------------------------------------------------------

Friday, August 10, 2012

Refresh ADF page programmatically.

Several times, we might have the need to refresh the page programatically. Every page is internally given an ID and can be refreshed by this ID as follows in the backing bean.

Refresh a page programmatically.

String refreshPage = fctx.getViewRoot().getViewId();
ViewHandler vh = fctx.getApplication().getViewHandler();
UIViewRoot UVi = vh.createView(fctx,refreshPage);
UVi.setViewId(refreshPage);
fctx.setViewRoot(UVi);

Thursday, August 9, 2012


ADF Glossary


action binding
A binding for command components, such as buttons or links, to built-in or custom methods on the data control, or to built-in collection-level operations (such as, Create, Delete, Next, or Previous). An action binding object encapsulates the details of how to invoke a method and what parameters (if any) the method is expecting.



activity
A piece of work that is performed when an ADF Controller task flow runs, for example, a method call or view.



ADF binding filter
A servlet filter that ADF web applications use to preprocess any HTTP requests that may require access to the binding context.



ADF Business Components
A framework that simplifies the development, delivery, and customization of business applications for the Java 2 Platform. You use ADF Business Components to define associations between entity objects, view objects, and application modules to reflect the foreign keys present in the underlying tables.



ADF Controller layer
A mechanism that provides an enhanced navigation and state management model on top of JSF. This mechanism declaratively defines navigation using control flow rules.



ADF Faces Rich Client (RC)
A set of standard JSF components that include built-in Ajax functionality.



ADF Model layer
A layer that implements JSR-227 service abstraction called the data control.



application module
A transactional component that UI clients use to work with application data. It defines an updatable data model and top-level procedures and functions (called service methods) related to a logical unit of work. This unit of work is related to an end-user task.



binding context
A container object that holds a list of available data controls and data binding objects. The DataBindings.cpx files define the binding context for the application.See also data control.



bounded task flow
A specialized form of ADF Controller task flow that has a single entry point and zero or more exit points. It contains its own set of private, control flow rules, activities, and managed beans. A bounded task flow allows reuse, parameters, transaction management, and reentry. When dropped on a page, it becomes a region.



control flow
An ADF Controller activity that enables navigation between other activities in an ADF task flow. The control flow links one activity to another in a task flow.



data control
XML configuration files that describe a service. At design time, visual tools like JDeveloper can leverage that metadata to UI component to be declaratively bound to an operation or data collection.



Data Controls panel
A panel in JDeveloper that lists all the data controls that have been created for the application's business services and exposes all the collections (row sets of data objects), methods, and built-in operations that are available for binding to UI components.



entity object
An object that represents a row in a database table and that simplifies modifying its data by handling all data manipulation language operations for you. Entity objects are ADF Business Components that provide the mapping to underlying data structures.



invoke action
An action that binds to a method that invokes the operations or methods defined in an action or a method action binding during any phase of the page lifecycle. See also action binding.



iterator binding
A binding to an iterator that iterates over view object collections. There is one iterator binding for each collection used on the page. All of the value bindings on the page must refer to an iterator binding in order for the component values to be populated with data at runtime.
Contrast with variable iterator and method iterator.



list of values (LOV)
Input components that allow a user to enter values by picking from a list that is generated by a query



MDS
An application server and Oracle relational database that keep metadata in these areas: a file-based repository data, dictionary tables (accessed by built-in functions) and a metadata registry. One of the primary uses of MDS is to store customizations and persisted personalization for Oracle applications



method iterator
A binding to an iterator that iterates over the collections returned by custom methods in the data control. An iterator binding that is always related to a method action binding object. The method action binding encapsulates the details about how to invoke the method and what parameters the method is expecting. The method action binding is itself bound to the method iterator, which provides the data.



Oracle ADF
An end-to-end application framework that builds on Java Platform, Enterprise Edition standards and open-source technologies to simplify and accelerate implementing service-oriented applications.




page definition file
A file that defines the binding objects that populate the data in UI components at runtime. For every page that has ADF bindings, there must be a corresponding page definition file that defines the binding objects used by that page.


region
An ADF Controller UI component whose content is based on a task flow definition. When first rendered, the region's content is that of the first view activity in a task flow.



task flow
A set of ADF Controller activities, control flow rules and managed beans that interact to allow a user to complete a task.


unbounded task flow

A set of activities, ADF control flow rules, and managed beans that interact to allow a user to complete a task. An unbounded task flow has a single point of entry.



value binding
A binding used by ADF view UI components that display data. Value bindings range from the most basic variety that work with a simple text field to more sophisticated list and tree bindings that support the additional needs of list, table, and tree UI controls.



value iterator
An ADF Model iterator pointing to a collection that contains only one data object whose attributes are the binding container variable. Contrast with method iterator and value iterator iterator.



variable iterator
A binding to an iterator that exposes all the variables in the binding container to the other bindings. While there is an iterator binding for each collection, there is only one variable iterator binding for all variables used on the page. Contrast with method iterator and value iterator iterator.



view accessor
An ADF Business Components object that points from an entity object attribute (or view object) to a destination view object or shared view instance in the same application workspace. The view accessor returns a row set that by default contains all the rows from the destination view object.



view object
An ADF Business Components object that represents a SQL query and simplifies working with its results. The SQL language is used to join, project, filter, sort, and aggregate data into the shape required by the end-user task being represented in the user interface.

OAF - Change standard logo, background color

Customizing Your Web Pages
The following steps explain how to customize certain aspects of your Oracle Self-Service Web Applications pages.

To add your company logo:
You can replace the default Oracle logo with your own corporate logo. Your logo will then appear on every page.

1. Create a GIF file containing your corporate logo and name it FNDLOGOS.gif.
2. Place the file in the directory as defined in the Web Listener.
If you have a multilingual install, you must also copy this file into the other language location.

To change the background color:
You can replace the background on every page with your own choice of background color and texture.

1. Create a JPEG file containing your background and name it ICXBCKGR.jpg.
2. Place the file in the directory as defined in the Web Listener.
If you have a multilingual install, you must also copy this file into the other language location.