Wednesday, August 24, 2016

Insert rows at last Index with line numbers

Scenario - In master-child related tables, insert rows in Child Table at the last index  and add line number accordingly.

Solution -

Case 1:
In case you want to persist the line number below code in the child Table's VOImpl works -

    @Override
    public void insertRow(Row row) {
        last();
        next();
        row.setAttribute("LineNumber", getEstimatedRowCount() + 1);
     super.insertRow(row);
    }

Case 2:
If line numbers are just to be used for display purpose, Then in af:Table/af:Iterator
use the varStatus feild to a variable, say rs, and use 

  <af:column headerText="Line Number" id="c25" >

   <af:outputText value="#{rs.index+1}"  id="ot21"/>

</af:column>


Hope it helps :-)