Thursday, December 17, 2015

varStatus variable in ADF table

There is an inbuilt feature in ADF table called varStatus variable, which can be used to display a auto increment number for any dummy column in adf page.

Suppose if there is a requirement to display serial numbers in adf page for each row, we can create a column name and use the varStatus attributes index method to achieve this.

Step1: In af:table source add the variable varStatus like this.

<af:table value="#{bindings.DepartmentsView1.collectionModel}" var="row"                         
                         varStatus = "vs" >

Step2: add a dummy column Serial Number to the table like this.

<af:column id="c5" headerText="Serial Number"/>

Step3: add output text component in the above column like this. and Make the value attribute to the vs.index+1. first vs.index will have value 0 . So from there we are increment by 1.

<af:column id="c5" headerText="Serial Number">
 <af:outputText value="#{vs.index+1}" id="ot1" />
                    </af:column>

Step4: Run the page you will get the following output.




but if you want to access this varStatus value from a managed bean you wont access as the documentation says that the value will be lost once its rendering.

An alternate approach to get the value of varStatus is getting the row index. 

we can Get the row index  by following code

  1. RowKeySet selectedEmps = getTable().getSelectedRowKeys();  
  2.     Iterator selectedEmpIter = selectedEmps.iterator();  
  3.     DCBindingContainer bindings = (DCBindingContainer) BindingContext.getCurrent().getCurrentBindingsEntry();  
  4.     DCIteratorBinding empIter = bindings.findIteratorBinding("EmployeesView1Iterator");  
  5.     RowSetIterator empRSIter = empIter.getRowSetIterator();  
  6.     while (selectedEmpIter.hasNext())  
  7.     {  
  8.       Key key = (Key) ((List) selectedEmpIter.next()).get(0);  
  9.       Row currentRow = empRSIter.getRow(key);  
  10.       System.out.println("Row Index= " + (empIter.getViewObject().getRangeIndexOf(currentRow) + 1));  
  11.     }  

Cheers... keep learning... 


                

Hide Query By Example of PanelCollection on page load

Hi All, If there is a table with filterable is true. If you want to display QueryByExample then surround this table with panelCollection....