Saturday, November 26, 2011

ADF: Panel Tabbed Inter-Region Communication through shared bean datacontrol

Tested with JDeveloper 11.1.1.2

Use Case

  • JSF Page with two tabs (Departments, Employees)
    image The DepartmentName is rendered as a command link. If the user clicks on a DepartmentName the view changes on to the Employees Tab and filters the data
    image
  • In each tab there is an static adf region (bound to fragment based BTF)
    image
In summary we need the following to do:
  • DepartmentName as command link
  • View switches to the Employees Tab
  • Tab text should change to “Employees (<DepartmentName>)
  • On the employees tab - of course – only the corresponding entries should be displayed
  • The employees tab contains a button to remove the “global” filter.

How to do it?

Create DataExchange Bean as follows
public class DeptEmpExchange {
    private Number deptId;
    private String deptName;
    public DeptEmpExchange() {
        super();
        System.out.println("DeptEmpExchange created " + this);
    }
    public void setDeptId(Number deptId) {
        this.deptId = deptId;
    }
    public Number getDeptId() {
        return deptId;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
    public String getDeptName() {
        return deptName;
    }
    /**
     * Exposed as DC Operation.
     * Called from the dept btf
     * @param deptId
     * @param deptName
     */
    public void onDepartmentChange(final Number deptId,
                                   final String deptName) {
        System.out.println("onDepartmentExchange called: " + deptId + "/" + deptName);
        setDeptId(deptId);
        setDeptName(deptName);
        View1Bean view1 = (View1Bean)JSFUtils.resolveExpression("#{View1Bean}");
        view1.getEmpTab().setDisclosed(true);
        view1.getDeptTab().setDisclosed(false);
        view1.setEmpTabText("Employees ("+deptName+")");
        AdfFacesContext.getCurrentInstance().addPartialTarget(view1.getPanelTabbed());
    }
And expose as JavaBean DataControl.
Now, on depts page fragment: drop the exposed operation onto the command link and provide the parameters from the current row.
image
The refresh of the panel tabbed is done programmatically in the onDepartmentChange(..) method. In order to refresh the emp btf with the new dept id configure the following bindings / properties on the main page
image
- create an attribute binding on the deptId from the DeptEmpExchange Bean.
- bind the tf input parameter to the attribute binding
- do not forget to set refresh=ifNeeded => this causes the btf to refresh in case the input params will change.
Implementing the “remove global filter” functionality is pretty simple. Just drag the onDepartmentChange-Operation from the data control palette on to the toolbar and adjust the text.
image

image
I hope I have not forgotten any important steps.

Download JDev11112Workspace

Update on Dec 19th 2011: Added Sample Application

Thursday, November 24, 2011

ADF Faces: Navigate on Checkbox selection

Used in Version: 11.1.1.2

As you may have noticed there is no action attribute on af:selectBooleanCheckbox. So how could you trigger a navigation case if user changed selection state of the checkbox.

In a customers scenario I need to trigger a navigation in a BTF from a checkbox insige a jsff

<af:selectBooleanCheckbox label="Klick me" id="sbc1"
                                       selected="#{MyBean.selected}"
                                       autoSubmit="true"/>

image

MyBean.java looks like

 public void setSelected(String value) {
final FacesContext context = FacesContext.getCurrentInstance();

if ("true".equalsIgnoreCase(value)) {
// checkbox is selected
context.getApplication()
.getNavigationHandler()
.handleNavigation(context,null,"selected");
return;
}

// checkbox is not selected
context.getApplication()
.getNavigationHandler()
.handleNavigation(context,null,"notSelected");
}

Tuesday, November 22, 2011

ADF Talk on Youtube started

Today Ulrich and me started a series of sessions on ADF Topics.

In ADF Talk Session 1 we are introducing a way to integrate PL/SQL Code into ADF fusion applications. The video shows the usage of custom jdeveloper extension: TEAM Application Module from Database Package. See it in action.

Monday, November 21, 2011

My DOAG 2011 Slides – Upgrade Guide for Oracle ADF on WebLogic Server

Just translated my german slides from DOAG 2011 and uploaded those to slideshare.
Hopefully someone will find it useful. At the conference there were just too few attendees…
http://www.slideshare.net/multikoop/doag-2011-upgrade-guide-for-oracle-adf-on-weblogic-server

Friday, November 11, 2011

ADF 11.1.2.1 - clicktoedit table, createinsert, rollback bug?

ADF version: 11.1.2.1
Firefox: 5.0

Prerequistes

-Using ADF BC
-Create the most simple jsf page declarativly (no custom java code)
--table features: single selection, sorting, filtering
--change table attributes: editingMode=clickToEdit

Steps to reproduce

1. start http://127.0.0.1:7101/TestInsertIntoClickToEditTable2-ViewController-context-root/faces/view1

0000@2660_2660-412669e935ee8dd8

[notice the yellow marked rows.]

2. Now Click on CreateInsert

0001@2660_2660-412669e9366af37c

OK, new row is inserted and can be edited now.

3. Click on Rollback-Button (or Execute-Button)

0002@2660_2660-412669e937240796

What happened to the last two rows?

Further issue: clicktoedit not working on some rows

0003@2660_2660-412669e9385e0e69

You may click as often you want. The row won't change into edit mode. In the log window you will see

<FacesCtrlHierBinding$FacesModel> <makeCurrent> ADFv: Keine Zeile gefunden für rowKey: [oracle.jbo.Key[191 ]].

Known workaround so far

1. Click the Execute-Button after Rollback.

2. Bind Rollback action to a backing bean method and do the following (Rollback + setActiveRowKey)

/**
* Rollsback and Re-Executes the table iterator
* @param actionEvent
*/
public void onRollback(ActionEvent actionEvent) {
    final DCBindingContainer bc = (DCBindingContainer)getBindings();
    bc.getOperationBinding("Rollback").execute();

    setActiveRowKey(bc);
}

/**
*
* @param bc
*/
private void setActiveRowKey(final DCBindingContainer bc) {
    final DCIteratorBinding empIter = bc.findIteratorBinding("EmployeesView1Iterator");
    final Row newRow = empIter.getCurrentRow();
    final ArrayList activeRowKeyList = new ArrayList();
    activeRowKeyList.add(newRow.getKey());
    getEmpTable().setActiveRowKey(activeRowKeyList);
}

public BindingContainer getBindings(){
    return BindingContext.getCurrent().getCurrentBindingsEntry();
}

Download

Sample Application: http://www.box.net/s/od2t8en8ojo3hho704uz

Similiar issues

http://adfbugs.blogspot.com/2010/03/rollback-does-not-refresh-current-row.html

JDev 11.1.2.1 – Clear WLS Log tab Bug?

Applies to JDeveloper: 11.1.2.1

Problem Description

After starting the integrated WLS from JDev the wls log is displayed in the log tab. Open mouse context menu and “clear” item is not activated

image

I have no chance to clear the log tab!! Arghh.

Is there any good reason for this behaviour? ( not beeing able to clear the log). The memory consumption is already enormous. Dear Oracle, please let me clear the log tab again…

Never seen this issue in 11gR1 versions.

Is there any workaround?