Flipkart Search

Tuesday 30 December 2014

Merge two Columns into one column while showing data Seperately

Use case scenario:  You may need to show your two column header as well as data into a single ADF Table column. 
Please refer the below image for use case:

ADF has made this use case very simple.
You have just wrap your existing(required) Columns into a single column and its done.

Here is the required code sample:
 <af:column headerText="Emplyee Name"  id="c5" align="center">
          <af:column headerText="First Name" id="c8">
                     <af:outputText value="F_Name #{vs.index+1} " id="ot6"/>
          </af:column>
          <af:column headerText="Last Name" id="c9">
                    <af:outputText value="L_Name #{vs.index+1}" id="ot5"/>
          </af:column>
 </af:column>

Implement selectBooleanRadio in Table Column and show it selected by row selection

Here is use case scenarios:
1. A column with radio button. At a single point of time only one radio button should be shown selected in that column.
2. Selecting the radio button will select that row and vice-versa.

Point no. 1 is achieved by simply drag and drop of selectBooleanRadio component.


 <af:column headerText="Select" id="cs4" rowHeader="true" width="50">       <af:selectBooleanRadio text="" label="Label 1" group="RadioButtons"                                 id="sbr1"/> </af:column>
 Remember to add group="RadioButtons" attribute.

For point no. 2 we have to make a javaScript call.
And here is the required code in jspx or jsff.
  <af:resource type="javascript" source="/js/custom.js"/>
And in custom.js add these Lines.

function rowSelectionListener(evt) {
    var table = evt.getSource();
    var selectedRowKey;
    for (key in table.getSelectedRowKeys()) {
        table.findComponent('sbr1', key).setValue(false);
        selectedRowKey = key;
        break;
    }
    table.findComponent('sbr1', selectedRowKey).setValue(true);

Special thanks for point 2 goes to ADF Goodies.
Here is the Link

Monday 22 December 2014

Insert new row at the end of an ADF Table

In some of case you may want to insert a new row at the end of the table then this method will come handy.

 public String CreateInsert() { 
DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
        DCIteratorBinding dcIterBind =
            (DCIteratorBinding)bindings.get("EmployeeView1Iterator");
        Row newRow = dcIterBind.getViewObject().createRow();
        newRow.setNewRowState(Row.STATUS_INITIALIZED);
        ViewObject vo = dcIterBind.getViewObject();
        vo.last();
        // to insert row at the end of the table
        vo.next();
        vo.insertRow(newRow);
        return null; 

}