Thursday 20 December 2012

Creating Advanced Table in Advanced Table in OAF

Hi Friends  this is about creating Advanced Table in Advanced Table.
My Friend ravi provided some of the impotent message for creating this functionality.
Thanks Ravi

For developing above page we need to create Association , View Link ,Entity Objects,View Objects, and Application Module.
View Part:

First create a advanced table and assign properties of advanced table:


Next step :create a detail Advanced Table and assign the properties of detail table:



view Part is completed.

Coding Part:

Create a controller and create a custom method for adding child row in detail table.

    public void addRowIntoDetail(OAPageContext pageContext, OAWebBean webBean,
                                 OAApplicationModule am, int iterator) {
        // get a handle to inner table
        RowSet innerRowSet = null;
        int counter = 0;
        int rowCnt = -1;
        OARow row = null;
        String subLrNo = null;
        String LrLineId = null;
        OAViewObject LrLinesVO =
            (OAViewObject)am.findViewObject("ViewObjectName");
        ArrayList subLrDtls = new ArrayList();
        OAAdvancedTableBean innerTable =
            (OAAdvancedTableBean)webBean.findChildRecursive("region3");

        // create an enumerator
        OAInnerDataObjectEnumerator enum1 =
            new OAInnerDataObjectEnumerator(pageContext, innerTable);
        while (enum1.hasMoreElements()) {
            innerRowSet = (RowSet)enum1.nextElement();
            // get all rows
            Row[] rowsInRange = innerRowSet.getAllRowsInRange();
            System.out.println(" Inner Table Fetched Row Count :" +
                               innerRowSet.getFetchedRowCount());

            if (iterator != -1) {
                if (counter == iterator)
                    break;
            }
            counter++;
 
        }


        if (innerRowSet.getAllRowsInRange().length < 10 )
            rowCnt = innerRowSet.getAllRowsInRange().length;
        else
            rowCnt = innerRowSet.getAllRowsInRange().length - 1;
         
        OARow newChallanRow = (OARow)innerRowSet.createRow();

        innerRowSet.insertRowAtRangeIndex(rowCnt,newChallanRow);
        newChallanRow.setNewRowState(Row.STATUS_INITIALIZED);

    }

 call the above method in process request and execute Master View object.


in Process form requset:



      OAApplicationModule am=(OAApplicationModule)pageContext.getRootApplicationModule();
   
      String source = pageContext.getParameter(SOURCE_PARAM);
      String event = pageContext.getParameter(EVENT_PARAM);
   
      String innerTab = null;
      String level = null;
      int hLvl = -1;
      int Startindex = source.indexOf("___");
      if (Startindex != -1) {
          innerTab = source.substring(0, Startindex);
          level = source.substring(source.length() - 1, source.length());
          hLvl = Integer.parseInt(level);
          System.out.println("Inner Tab is " + innerTab + " level is :" +
                             level);
      }
      if ("addRows".equalsIgnoreCase(event) &&
          "region3".equalsIgnoreCase(innerTab)) {
       
       
          OAAdvancedTableBean innerTable =
            (OAAdvancedTableBean)webBean.findChildRecursive("child region");
         
          // create an enumerator
          OAInnerDataObjectEnumerator enum1 =
            new OAInnerDataObjectEnumerator(pageContext, innerTable);
          // In case you want to add new rows in this RowSet, you can do the same
           RowSet innerRowSet = (RowSet) enum1.nextElement();
          OARow newRow = (OARow) innerRowSet.createRow();
       
       
          innerRowSet.insertRow(newRow);
       
       
      }

Just save and run your page.

6 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Hi Raju,

    Nice to see your Blog.

    Good work, keep posting new things man..

    ReplyDelete

  3. I have implemented table-In-Table in OAF. Master table and Child Table – both are classic tables and both are EO based VO – hence created AO (composite Association) as well as VL

    Now, Child table has “Add New Row” button. When I Click on this button, expectation is that the row is added only to the child of the current master. But its adding a row in all the master records.

    Can you help me? Its kind of urgent!

    Here is the code that I am using: (exactly same as per Dev Guide)

    if ("addNewDowntimes".equals(pageContext.getParameter(EVENT_PARAM)))
    {
    OATableBean innerTable = (OATableBean)webBean.findChildRecursive("DowntimeTableRN");
    OAInnerDataObjectEnumerator elements = new OAInnerDataObjectEnumerator(pageContext, innerTable);
    while (elements.hasMoreElements())
    {
    RowSet innerRowSet = (RowSet) elements.nextElement();

    Row []rowsInRange = innerRowSet.getAllRowsInRange();
    OARow newRow = (OARow) innerRowSet.createRow();
    innerRowSet.insertRow(newRow);


    }//END of While

    }// end of 124 IF

    ReplyDelete
  4. Hi Raju,

    detail table new row creation

    Can you send the exact steps and code

    ReplyDelete
  5. i followed your post, but when i click on Add row, it's creating in first row only.

    eventhough i click on 2nd and 3rd rows of add button . It's creating new row in first only

    ReplyDelete