1 2 Previous Next 17 Replies Latest reply: Jul 16, 2008 9:54 AM by 596061 RSS

    How to get First record in a table

    596061
      Hi,

      I have created a table, at a time 20 records are displayed in the table.
      When the 21-40 records are displayed in the table, and the page is refreshed.. then first 20 records are displayed.

      How can I display the current records i.e., 21-40 records when I refresh the page?
      Please give me a solution for this.
      Thanks.
        • 1. Re: How to get First record in a table
          557833
          Are you talking about the page refresh through OAF code or the refresh button?

          The logic you need to follow is to make sure that you maintain the state of the VO which will maintain the pointer to rows.

          --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                               
          • 2. Re: How to get First record in a table
            596061
            Hi Shiv,
            I am talking about the page refresh through OAF code.
            How can we maintain the state of the VO?
            Thanks.
            • 3. Re: How to get First record in a table
              583651
              For that u need to catch the navigation event and have a global variable to store the newRangeStart value in it and use VO.setRangeStart(globalVariableName);

              if (GOTO_EVENT.equals(pageContext.getParameter(EVENT_PARAM)))
              {
              String value = pageContext.getParameter(VALUE_PARAM);
              if (value != null)
              {
              int val = Integer.parseInt(value);
              int newRangeStart = val; //Record Number of Current Navigation
              }
              }

              Thanks
              Babu
              • 4. Re: How to get First record in a table
                596061
                Hi Babu,

                How can we get the current records number?
                Thanks
                • 5. Re: How to get First record in a table
                  557833
                  user593058,

                  Check the Navigation section of Advanced table in Dev guide.

                  --Shiv                                                                                                                                                                           
                  • 6. Re: How to get First record in a table
                    596061
                    Hi,

                    Where should I place VO.setRangeStart(globalVariableName) statement? I mean in VO or AM.

                    I have tried placing it in AM... but its displaying the last records (i.e., there are 105 records, if I set the Range start as 10 then it is displaying the last 5 records 101-105).
                    • 7. Re: How to get First record in a table
                      SumitSharma
                      Please have the code in the AM itself.
                      Before you navigate to some other page (or any other type of Page refresh), you get the absolute index of the first row in the rowset range. For this purpose, you can try vo.getRangeStart(). This would return an integer.

                      Now post refresh action, you can do a vo.setRangeStart(int) to the same integer value retrieved earlier. If you are showing 20 records at a time, you can also do a vo.setRangeSize(20).

                      Please try this and let us know your observations.

                      Thanks
                      Sumit
                      • 8. Re: How to get First record in a table
                        596061
                        Hi Sumit,

                        I have followed the following steps, but still it is displaying the last five records.. when the page is refreshed:

                        I have got the record number whenever the Next or Previous buttons of a table are clicked.
                        Passing this number to the AM, in AM I am setting the Startrange to it and the Size to 20.
                        Thanks,
                        • 9. Re: How to get First record in a table
                          SumitSharma
                          Please check if there is some other code resetting the VO.
                          • 10. Re: How to get First record in a table
                            596061
                            Sumit,
                            I am sure that the VO is not getting reset anywhere.
                            Is there any other way to acheive this.
                            Thanks
                            • 11. Re: How to get First record in a table
                              628722
                              Hi user593058

                              I had written this code to returns the row at the given absolute index of the View Object. Hope you can tweak this code to suit your need.

                              public static Row getFetchedRowAtIndex(ViewObject vo, int index)
                              {
                              Row row = null;
                              RowSetIterator rsi = null;
                              try
                              {
                              rsi = vo.createRowSetIterator(null);
                              rsi.setRangeStart(0);
                              rsi.setRangeSize(rsi.getFetchedRowCount());
                              row = rsi.getRowAtRangeIndex(index);
                              }
                              finally
                              {
                              if (rsi != null)
                              {
                              rsi.closeRowSetIterator();
                              }
                              }
                              return row;
                              }
                              • 12. Re: How to get First record in a table
                                596061
                                Thanks All.
                                The problem is because, I have set the range with what ever is returned by 'String value = pageContext.getParameter(VALUE_PARAM);' statement.

                                Now it got resolved as I have decremented the value of 'value' variable and set it as the setRangeStart.
                                • 13. Re: How to get First record in a table
                                  596061
                                  Hi,

                                  There are two tables in an OA page.
                                  I need to get the first record number from both the tables, how can we achieve this?

                                  Please help me, it is urgent.

                                  Thanks in advance.
                                  • 14. Re: How to get First record in a table
                                    SumitSharma
                                    Two options:
                                    1. Vo. first()
                                    Returns the first row of the VO resultset if the VO is already executed. Otherwise executes it and then gives the reference of the first row

                                    2. vo.reset()
                                    vo.next()
                                    I recommend this approach as this one first resets the VO and then takes the pointer to the first row. This approach never executes the query.

                                    Regards
                                    Sumit
                                    1 2 Previous Next