Friday, January 10, 2014

How to Add New Row to a Table Region in OAF

How to add new row to table region in OAF

Now we are going to learn about how to add a new row to table region.
Suppose we have a requirement that when we click on add button it has to create a new row to enter the data.




Step 1:- Right click on table region select footer.

Step 2:- right click on table footer select new -- > addTableRow.

            




Write the below code in the processFormRequest of a controller 


OAApplicationModule  am = (OAApplicationModule)pageContext.getRootApplicationModule();      
OAAdvancedTableBean tableBean = (OAAdvancedTableBean)webBean.findIndexedChildRecursive("PdqSystemParametersEOVORN");
       
      OATableFooterBean footerBean = (OATableFooterBean)tableBean.getFooter();

      if(footerBean != null)
      {
          OAAddTableRowBean addTableRowBean = (OAAddTableRowBean)footerBean.findIndexedChild("addTableRow1");

          if(pageContext.getParameter("event") != null && "addRows".equals(pageContext.getParameter("event")))
          { 
              am.createAnotherRow();       
   DBTransaction dbt = am.getDBTransaction();
              dbt.commit();
            }                
       }


Create one method called createAnotherRow() in am.

    public void createAnotherRow()
    {
        Row row1 = null;
        OAViewObject VO1 = null;
        VO1 = getPdqSystemParametersEOVO1();         
        row1 = VO1.createRow();
        VO1.setCurrentRow(VO1.last());         
        VO1.next();
        VO1.insertRow(row1);
        row1.setNewRowState((byte)-1);
        row1.setNewRowState((byte)-1);

    }

Now run the page and see the output.



Now click on add button.



The new row has been created.



     

4 comments:

  1. Hi , Can you provide the implementation of getDBTransaction(); and getPdqSystemParametersEOVO1(); methods

    ReplyDelete
    Replies
    1. getPdqSystemParametersEOVO1();
      this is nothing but your VO(view Object).

      getDBTransaction();

      this is a standard method.

      Delete
  2. The Column "Parameter" and "Description" are messageStyledText, but how is it MessageInputText when new row is added? Can you please help me

    ReplyDelete
  3. Hey - can you please share the coding for AM.java & Controller logic for the page which you mentioned above

    ReplyDelete