Showing posts with label ADF Faces. Show all posts
Showing posts with label ADF Faces. Show all posts

Saturday, March 2, 2013

Customizing the Columns of a Pivot Table


1. Add the pviot table to the page.

2. Add varStatus and var attributes to dvt:pivotTable. Add dvt:dataCell, a switcher and configure as below

3. You can add a button, link etc.


4. Download the complete example here.

Note: If you are using export, the switcher component does not work. Add rendered property ( rendered="#{cellStatus.cellIndex.column==0} ) to control the values exported.

Thursday, February 28, 2013

Using af:Iterator with master/detail to display data in custom layouts


Below example shows steps to use af:iterator in a master/detail senario

1. Create a ADF BC components(EO, VO, AM) with the viewlink for master/detail.

2. Drag and drop the master on to the page as tree table.

3. Create the first iterator to access the master collection via above tree binding, create the second iterator via the accessor binding. (Accessor name is present in the binding defination also in the view link defination)

4. You can create different combination of layout with this approach.



5. You can download the complete example here.

Sunday, February 3, 2013

ADF: Passing parameter from EL Expression workaround


Below example show a workaround to pass a single parameter from ELexpression into a managed bean.

1. Create a getter method in the managed bean that returns a Map. In this method return an anonymous subclass of hashmap. Override the get method use the parameter passed from the EL expression.



2. Pass the parameter from the EL expression using the box syntax.






3. You can also access bindings to pass a parameter with a similar syntax.


You can download the example here.

Sunday, January 6, 2013

ADF: Default Detail, Only One Detail Row can have the default flag set



     1. Create ADF BC components and setup the AM Datamodel for master detail. From the data control panel drop the detail as Master Form and Detail Table.



      2.       Drop the Preferred Flas as a Single Selection Column, Boolean Checkbox on the detail table. Choose the selected and unselected values for the checkbox.







       3.       Edit the properties of the Checkbox, add auto submit to true and set partial trigger on the detail table to the checkbox. Add a value change listener and bind it to a bean proeperty.


        4.       Add logic in value change listener to update all other rows when a new default row is selected.



       5.       Run the application and select a new default row, you can observe that the other default row already selected is cleared.


You can download the complete application here.

Saturday, December 29, 2012

ADF Global Style Selectors, AFStretchWidth and others

ADF Faces provides a easy way to style components using Skinning.

Apart from skinning components, Global Style Selectors help with layout of the components. AFStretchWidth is one of the most frequently used global style class used to stretch a component horizontally.

For a complete list of you can browse through Oracle Documentation here.

Sunday, September 23, 2012

dvt:pieGraph custom colors using static or programatic series

To set the colors of slices in a pieGraph you can use the below options.

1. Static settings
       If the groups for slices are are constant and are available in specific order you can used the below config.


          <dvt:seriesSet>
            <dvt:series index="0" color="#006ba5"/>
            <dvt:series index="1" color="#026ba5"/>
            <dvt:series index="2" color="#036ba5"/>
            <dvt:series index="3" color="#046ba5"/>
            <dvt:series index="4" color="#056ba5"/>
          </dvt:seriesSet>


2. Dynamic settings
       If the groups for slices are optional. i.e the query does not return specific rows in cases and to assign the specific colors for specific groups you can use this option.

  • Create a public method in bean that returns a map. Here you can write logic to determine the colors.
  • Map it seriesMap attribute of dvt:series.

        <dvt:pieGraph id="pieGraph1" value="#{bindings.DeptEmpCount.graphModel}"
                      subType="PIE">
          <dvt:background>
            <dvt:specialEffects/>
          </dvt:background>
          <dvt:graphPieFrame/>
          <dvt:seriesSet seriesMap="#{homeBean.pieSeries}"/>
          <dvt:sliceLabel/>
          <dvt:pieLabel rendered="true"/>
          <dvt:legendArea automaticPlacement="AP_NEVER"/>
        </dvt:pieGraph>


    private Map<Integer,Color> colorMap;    
    public HomeBean() {
        super();
        colorMap = new HashMap<Integer,Color>();
        colorMap.put(10, new Color(111111));
        colorMap.put(20, new Color(222222));
        colorMap.put(30, new Color(333333));
        colorMap.put(40, new Color(444444));
        colorMap.put(50, new Color(555555));
        colorMap.put(60, new Color(666666));
        colorMap.put(70, new Color(777777));
        colorMap.put(80, new Color(888888));
        colorMap.put(90, new Color(999999));
        colorMap.put(100, new Color(900000));
        colorMap.put(110, new Color(800000));
    }
    
    public Map getPieSeries(){
        Map seriesMap = new HashMap();
        BindingContext context = BindingContext.getCurrent();
        DCBindingContainer bindings =  (DCBindingContainer)context.getCurrentBindingsEntry();
        DCIteratorBinding iteratorBinding  = (DCIteratorBinding)bindings.getIterBindings().get("DeptEmpCountIterator");
        RowSetIterator iter = iteratorBinding.getViewObject().createRowSetIterator(null);
        int index =0;
        while(iter.hasNext()){
            Integer departmentId = (Integer)iter.next().getAttribute("DepartmentId");
            Series s = new Series();
            s.setColor(colorMap.get(departmentId));
            seriesMap.put(index, s);
            index++;
        }
        return seriesMap;
    }

You can download the complete example here.

Saturday, September 22, 2012

af:treeTable custom Collapse All and Expand All buttons

To add the custom buttons to af:treeTable to Collapse All nodes and to Expand All nodes. Below are the steps


  1. Create a binding for treeTable in the backing bean.
  2. Add Two buttons For expand and collapse behaviors.
  3. Bind the button actionListeners to bean properties.
Use the below code in backing bean

    public void expandAll(ActionEvent actionEvent) {
        TreeModel model= (TreeModel) treeTable.getValue();
        JUCtrlHierBinding treeBinding = (JUCtrlHierBinding ) model.getWrappedData();
        ArrayList<JUCtrlHierNodeBinding> childList = (ArrayList<JUCtrlHierNodeBinding>)treeBinding.getChildren();
        List newKeys = new ArrayList();
        if(childList !=null){
            for(JUCtrlHierNodeBinding node: childList){
                newKeys.add(node.getKeyPath());
            }
        }
        treeTable.getDisclosedRowKeys().addAll(newKeys);
        AdfFacesContext.getCurrentInstance().addPartialTarget(treeTable);
    }

    public void collapseAll(ActionEvent actionEvent) {
        treeTable.getDisclosedRowKeys().clear();
        AdfFacesContext.getCurrentInstance().addPartialTarget(treeTable);
    }

Note: Above code works for first level of node expansion, if you need to expand all levels you need to iterate to add all keypaths. Also the range size iterator needs to be set to -1 if you need all rows to be expanded, otherwise only the rows in the current range will be expanded.

Complete example can be downloaded here.
Related Posts Plugin for WordPress, Blogger...