Tuesday, April 29, 2014

How to use route activity in ADF taskflows?

If we would like to route the flow inside a taskflow based on the outcome of an expression, then we should use the Route activity.

Step1: Configure the Route activity as shown below in the taskflow
























In the above taskflow we observe that the router1 activity is the default activity. But where should the navigation go in the next step is determined by the expressions configured in the route activity

Step2: Configure the outcomes based on the outcome of an EL expression as shown below.
















Note:
  1. The default outcome is mandatory for the route activity.
  2. If the router outcome matches a from-outcome on a control flow case, control passes to the activity that the control flow case points to.
  3. If none of the cases for the router activity evaluates to true, or if no cases are specified, the outcome specified in the router default outcome field (if any) is used.

Easy way to store a value in a memory scope variable on button, commandlink click in ADF.

We can use the af:setPropertyListener as mentioned below to achieve the same.

<af:commandButton id="cb3" blocking="true">
    <af:setPropertyListener from="#{row.employeeId}" to="#{pageFlowScope.address}"
                                           type="action"/>
</af:commandButton>

The setPropertyListener tag provides a declarative syntax for assigning values when an event fires. The setPropertyListener implements the listener interface for a variety of events, to indicate which event type it should listen for set the 'type' attribute.

Thursday, April 10, 2014

How to undo all the changes made to a component in adf? Undo all the changes made to a table?

Sometimes we might want to undo all the changes made to a component on clicking a button or a command link etc. in the managed bean.

ADF framework provides the API ResetUtils achieve the same. This can be used as follows

import javax.faces.component.UIComponent;
import oracle.adf.view.rich.util.ResetUtils;

      
UIComponent comp = ADFUtils.findUIComponent("t1");
ResetUtils.reset(comp );


findUIComponent method can be found here

On executing the reset method, All values submitted will be reset to null or empty, so that editable components will pull their values from the model.

Monday, April 7, 2014

How to get the url till context root in ADF managed bean?

import javax.faces.context.FacesContext;
import javax.faces.context.ExternalContext;
import javax.servlet.http.HttpServletRequest;

FacesContext facesCtx = FacesContext.getCurrentInstance();
ExternalContext ectx = facesCtx.getExternalContext();
HttpServletRequest req = (HttpServletRequest) ectx.getRequest();
String url = req.getRequestURL().toString();
return url.substring(0, url.length() - req.getRequestURI().length()) + req.getContextPath();


sample output

http://localhost:7501/EmployeeAppDemo-ViewController-context-root

Get the view object instance from the iterator in the backing bean in ADF?

import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCIteratorBinding;


BindingContext bindingContext = BindingContext.getCurrent();
DCBindingContainer dcBindings = (DCBindingContainer)bindingContext.getCurrentBindingsEntry() ;
DCIteratorBinding iterator = dcBindings.findIteratorBinding("EmployeesView1Iterator");
ViewObject vo = iterator.getViewObject();
  
Number empId =(Number)iterator.getCurrentRow().getAttribute("EmployeeId");

Accessing an element in the Java array or map using expression language?

Sometimes we might have the Java List or Map in the managed bean and we might want to access an element using either the index of the List or the Key of the Map.

We access the elements in the same manner for both the above cases and the code is as below.

value="#{viewScope.treeTableModel.newEmployeeMap['key']}"

or 

value="#{viewScope.treeTableModel.newEmployeeList[vs.index]}"

Thursday, April 3, 2014

Resolve weblogic.descriptor.BeanAlreadyExistsException: Bean already exists: exception

Sometimes while deploying the adf application, we get the following error. 

weblogic.descriptor.BeanAlreadyExistsException: Bean already exists: "weblogic.j2ee.descriptor.wl.LibraryRefBeanImpl@87de1187(/LibraryRefs[[CompoundKey: adf.oracle.domain]])"

This can be because of some configuration corruptions in the weblogic-application.xml file














Open the weblogic-application.xml and remove any duplicate library references if at all present.




Now try to deploy the application, it should work.


get the selected row in backing bean from af:table based on POJO?

import oracle.adf.view.rich.component.UIXTable;
import org.apache.myfaces.trinidad.model.RowKeySet;
import java.util.Iterator;

//get the table from table's binding getter method
UIXTable table = getEmployeeTable();
RowKeySet selectedRows = getEmployeeTable().getSelectedRowKeys();
Iterator selectedEmpIter = selectedRows.iterator();
while (selectedEmpIter.hasNext()) {
    Object rowKey = selectedEmpIter.next();
    table.setRowKey(rowKey);
    int index = table.getRowIndex();
    Employee row = (Employee)table.getRowData(index);
    System.out.println(row.get_empName());
    System.out.println(row.get_empNo());
}

Wednesday, April 2, 2014

How to test ADF application in ie7, ie8, ie9 even if you dont have those browsers?


Click F-12 to open the developer tools for the Internet explorer browser and then select the browser mode as shown below. Each ie browser offers downward compatibility view.

Tuesday, April 1, 2014

How to use resource bundle in adf application in simple steps?

Steps1:

Create a properties file or bundle file as shown below in the application resources









Step2


Add the following code to your jspx/jsff at the top after the namespaces declaration. Make sure to point to the absolute path as shown below

    <c:set var="appUIBundle" value="#{adfBundle['com.test.bundle.app']}"/>



Step3

Use the properties from the bundle as shown below

"#{appUIBundle.PROPERTIES_KEY}"