Please disable your adblock and script blockers to view this page

Search this blog

Monday 13 November 2017

ADF Basics: Add the row at the end of ViewObject's current RowSet in ADF

This post is about adding a row at the end of current rowset of viewObject without using table or any other UI components binding

Here I have a Department ViewObject (HR Schema), dropped as a table on page and a button to add new row, this button calls a method from model using binding layer 

Code in AMImpl

     * Method to add row at the end of viewObject
    public void addRowAtEnd() {
        //Get ViewObject
        ViewObjectImpl deptVo = this.getDepartmentsVO1();
        //Get current data RowSetIterator
        RowSetIterator rsi = deptVo.getRowSetIterator();
        //Get last Row of current Iterator
        Row lRow = rsi.last();
        //Get index of the last row
        int lrIndex = rsi.getRangeIndexOf(lRow);
        //Create a new row
        Row nRow = rsi.createRow();
        //Initialize that row
        //Add row in last of current rowset
        rsi.insertRowAtRangeIndex(lrIndex + 1, nRow);
        //Set newly created row as current row

Bean Code 

    /**Generic Method to get BindingContainer of current page,
    public BindingContainer getBindingsCont() {
        return BindingContext.getCurrent().getCurrentBindingsEntry();

     * Generic Method to execute operation
     * */
    public OperationBinding executeOperation(String operation) {
        OperationBinding createParam = getBindingsCont().getOperationBinding(operation);
        return createParam;

    /**Method to add new row
     * @param actionEvent
    public void addNewRowAction(ActionEvent actionEvent) {

and the result is - New Row added at the end of table

Cheers :) Happy Learning

No comments :

Post a Comment