1 2 Previous Next 20 Replies Latest reply: Feb 8, 2013 9:19 AM by Navneet01 RSS

    Initialize and insert new row in Adv table

    636775
      When I click add new row button in adv table footer, I want to add row, with predefined primary key values .

      for ex: col1=1 , col2=2 and col3 = sequence.nextval , the new row should get intialized by these values in the table.

      I did this in my CO :

      OAAdvancedTableBean tableBean = (OAAdvancedTableBean)webBean.findChildRecursive("advQTable");
      if (tableBean!= null)
      {
      OATableFooterBean tableFooterBean = (OATableFooterBean)tableBean.getFooter();
      if (tableFooterBean != null)
      {
      OAAddTableRowBean addTableRowBean = (OAAddTableRowBean)tableFooterBean.findChildRecursive("addTableRow1");
      System.out.println("got addtable row bean" );

      String incNum = (String)pageContext.getSessionValueDirect("incNum"); //pk field
      String probid = (String)pageContext.getSessionValueDirect("probid"); // pk field

      String qid = "55"; //im harcoding rt now, but this needs to be generated from db sequence.

      Serializable aserializable[] = {incNum,probid,qid};
      am.invokeMethod("getNewRow",aserializable);
      }

      AM :
      -----I tried several ways to set the attributes of current row to the given values, but I am unsuccessfull.
      Can anyone please help me with the code here.

      Thanks in advance.
        • 1. Re: Initialize and insert new row in Adv table
          Gauravv
          Hi,

          Set the insert rows automatically property of add new row button to be false.

          Now when the add new row button is clicked then "addRows" event is fired which you can capture in Controller

          invoke a method in AM

          if("addRows".equals(event))
          {          
          ap.invokeMethod("add");
          }

          public void add()
          {
          sapeEAAddressesVOImpl vo1 = getsapeEAAddressesVO1();
          Row row1 = (Row)vo1.createRow();
          vo1.insertRowAtRangeIndex(0,row1);
          row1.setAttrbute("col1","yes");//first column
          row1.setAttribute("col1","No");//second column
          int value = getOADBTransaction().getSequenceValue("name of sequence");
          row1.setAttribute("col3",value);//third column populated from sequence.
          row1.setNewRowState(Row.STATUS_INITIALIZED);
          vo1.setCurrentRow(row1);

          }

          Thanks,
          Gaurav

          Edited by: Gauravv on Aug 31, 2009 8:28 PM
          • 2. Re: Initialize and insert new row in Adv table
            Reetesh Sharma
            Hi,

            Another standard way to do this is generate create Method in your EOIMPL class and in create Method write your defaulting logic.

            Regards,
            Reetesh Sharma
            • 3. Re: Initialize and insert new row in Adv table
              Gauravv
              Thats right Reetesh!!!

              Thanks for the information!!!

              Gaurav
              • 4. Re: Initialize and insert new row in Adv table
                Gauravv
                HI,

                Did you try "addRows" event handling and inserting rows..by the code given???

                Thanks,
                Gaurav
                • 5. Re: Initialize and insert new row in Adv table
                  636775
                  I was doing the same currently. Thanks for code, it works. It inserted a new row at the top of the table. Im trying to figure out how to insert it in the end of the table ? any idea?

                  Few more questions(can you verify if the steps taken by me are correct ?)
                  - In adv table, added table footer--addTableRow1--set auto insert = false and rendered = False (otherwise a button was getting added in the UI)
                  - Then I added submitButton in tableFooter , with Actiontype= fireAction, event = addRows , caught this event in CO. and followed your steps.
                  - Added APPLY button on this page to commit the transaction.
                  • 6. Re: Initialize and insert new row in Adv table
                    AnilSharma
                    vo1.insertRowAtRangeIndex(0,row1); // Comment this line & Check
                    vo1.insertRow(row1); //Insert this line insted

                    Thanks
                    --Anil                                                                                                                                                                                                                                                                   
                    • 7. Re: Initialize and insert new row in Adv table
                      636775
                      I did that too, but it got inserted in second last position.
                      thx
                      • 8. Re: Initialize and insert new row in Adv table
                        Abdul Wahid
                        Hi,
                        Please use this.

                        vo1.insertRowAtRangeIndex(vo1.getRowCount()-1,row1);

                        However, please check behaviour for adding multiple rows also.

                        Abdul Wahid
                        • 9. Re: Initialize and insert new row in Adv table
                          Abdul Wahid
                          Addition to above,

                          Instead of vo1.insertRowAtRangeIndex(vo1.getRowCount()-1,row1),

                          try this also,
                          Instead of vo1.insertRowAtRangeIndex(vo1.getFetchedRowCount()-1,row1),

                          Reason is the behaviour of the getRowCount works. It executes the vo. Hence your new rows may be lost after call to this method.
                          In case of getFetchedRowCount, I am not sure will it count the custom added rows also.

                          So If above method's behaviour works well, then its quite okay, Else you should manually count all rows in your vo1's row set (above two methods also do same).
                          And then add your new row at specified rangeIndex by calling insertRowAtRangeIndex method.

                          Optionally, you can use insertRow also, however this method adds the new row at the current rows position and this row becomes the new current row. In your case it did not work cause your current row was still the first row. So to add the row at end, first iterate through row set and bring the iterator to the end or row set and then call insertRow method. InshaAllah that may solve your problem.

                          Abdul Wahid
                          • 10. Re: Initialize and insert new row in Adv table
                            Gauravv
                            Hi,

                            Try

                            Row row = vo.last();
                            vo.setCurrentRow(row);
                            Row row1 = vo.createRow();
                            vo.insertRow(row1);


                            Thanks,
                            Gaurav
                            • 11. Re: Initialize and insert new row in Adv table
                              579913
                              Hi,

                              Can some one help me with advanced table in advnced table implementation.

                              Using the dev guide i tried but egtting this error while trying to access the detail table.
                              java.lang.NullPointerException
                                   at oracle.apps.fnd.framework.webui.OABoundValueChildNodeList.getDetailRowSet

                              Any help will be highly appreciated.

                              Thanks,
                              Rma
                              • 12. Re: Initialize and insert new row in Adv table
                                Abdul Wahid
                                Nice Gaurav!!!
                                Short n Sweet.

                                Abdul Wahid
                                • 13. Re: Initialize and insert new row in Adv table
                                  Gauravv
                                  I was doing the same currently. Thanks for code, it works. It inserted a new row at the top of the table. Im trying to figure out how to insert it in the end of the table ? any idea?

                                  Few more questions(can you verify if the steps taken by me are correct ?)
                                  - In adv table, added table footer--addTableRow1--set auto insert = false and rendered = False (otherwise a button was getting added in the UI)
                                  - Then I added submitButton in tableFooter , with Actiontype= fireAction, event = addRows , caught this event in CO. and followed your steps.
                                  - Added APPLY button on this page to commit the transaction.

                                  Hi,

                                  verified the steps:

                                  1) In advance table, right click on that create new tablefooter and in that create a addtableRow.
                                  2) Set the properties : insert rows automatically to false.

                                  upto here it is fine

                                  but why have you set the rendered property as false...if the button is gettiing rendered then let it be ...

                                  set the Add Rows Label to prompt of this button say "AddRow" and Rows to add = 1

                                  Now there is no need for any submit button and fireAction. remove it...

                                  As the button "AddRow" is clicked automatically "addRows" event is fired.

                                  then in AM use

                                  vo.insertRow(row);

                                  instead of

                                  vo.insertRowatRangeIndex();

                                  Yes you are right that row gets added at the second last position...but this is standard behaviour.


                                  There is a note in Developer Guide

                                  Note: When you add another row, the row is added as the last row in the current range. The existing last row
                                  in the current range is pushed into the next range.

                                  Thanks,
                                  Gaurav
                                  • 14. Re: Initialize and insert new row in Adv table
                                    636775
                                    Thanks everyone for the help. I was able to insert/update the rows in the table.
                                    User was ok to have the new row inserted at the very top as long as he could sort rows .So I added sortable row_id field in UI , so that user can see which rows were inserted in what order.


                                    Abdul:
                                    The concepts were really well explained by you.
                                    I faced this issue with
                                    vo.insertRowAtRangeIndex(vo.getFetchedRowCount()-1,row);
                                    or vo.insertRowAtRangeIndex(vo.getRowCount()-1,row);
                                    Inserted at second last position. Also it inserted rows correctly in the first run. But after committing, If I tried adding new row again,it errored out.

                                    Invalid parameter value 11 for rangeIndex passed to method ViewRowSetIteratorImpl.insertRowAtRangeIndex. Explanation: index outside range
                                         at oracle.apps.fnd.framework.webui.OAPageErrorHandler.prepareException(OAPageErrorHandler.java:1223)

                                    No idea why.

                                    Gaurav-
                                    solution works like a charm.
                                    Regarding submitbutton , I removed it on your suggestion. I set the id of addTableRow1 to addRow and rendered it to true.
                                    I dint know that OAF considered it as an event. Because I kept looking for event property like we set for links and submit buttons, but I couldnt find one, so I had added submit button with action type and event=addRow initially.
                                    After catching the event it insertrow code works fine.

                                    Thanks all. I get to take away something everyday from this forum.
                                    1 2 Previous Next