Pagination of results.

Hi All,
Just wondering if anyone has come across a nice way to do pagination of results from a database call. I am getting back a populated container object (extended from Vector, for which I have no control over) in my jsp. I only want to display 10 objects from the container object per page (potentially it could contain 100's of objects). The user needs to be able to go back and forth through the pages as they wish. Any ideas or gotcha's that I should be aware of.
Cheers,
James.
P.S. Would it be easier if I was given the actual ResultSet object from the DB lookup.

I'm not gonna give you the code because it's a nice problem to work out but here's the way I did it:
Write a class called Pager
the constructor takes a Vector of all the objects you're paging over, the number of items you want on the page and the current page.
From there you can splice the Vector into the sublist that you need for the current page.
From there all you need to do is write a few simple methods:
void moveFirst()
void moveNext()
void moveLast()
void moveTo()
int getNumItems()
getCurrent() -> returns whatever you're storing in your Vector
boolean eof()
boolean hasMorePages(Vector allItems)
boolean hasPrevPages()
int getNextPage(int currentPage)
int getPrevPage(int currentPage)
int getStart()
int getEnd()
int getTotalPages(Vector allItems, int pageSize)
int getItemCount()
Good Luck

Similar Messages

  • Pagination changes result in master objects moving

    Whenever my pagination changes, either from documents in my book starting on an even page, or by inserting a page the objects set in my master pages move (generally toward the gutter). I can reapply the master page as a fix and select the option of using the master page size to put the objects back where they should be.
    This issue does not occur when I start from a template that I did not create and is known to not have this issue, but once I start making edits to the objects on the master pages that are necessary for my project the issue pops up. I'm duplicating existing boxes. And the perplexing thing is that when I just have "Words" in the boxes for my headers the issue does not occur, but when I enter the actual text that I need for my project it does. When I go back to "Words" the issue doesn't occur anymore. The text fits in the box, no preflight errors. The issue is popping up on my machine and one of my colleagues.

    1. You need to load the heirarchy along with product master data.
    2. You dont need any downtime for transaction data; guess you have delta.
    3. reg queries ( especially after change in hierarchy structure), the users should be educated of the change. If you have any hier variable on a any node and if that node is gone with change in hier, then you have to take care of that.
    4. If you have any variable on a hier node, the query will give error, if that node has gone as a change in the hierarchy.
    Ravi Thothadri

  • Servlet+pagination+search Result

    can u help me please it is very urgent code for pagination in servlet
    if i type anything into the search textbox and display 4 records per page then the 5th records should be in the next page
    i have used this query for search either number or character in the search textbox
    "Select * from record where sn LIKE ? OR NI LIKE ?";
    Where sn=Sanction number and NI =Name of the university
    if i search either sn or ni in the search box it will display all records per page
    i want to control 5 records per page how to do that in servlet
    in jsp page if i click on next and it should show the next page there i can seee the 6 -10 records
    Regards
    Akshatha

    Read the DB specific documentation how to retrieve subsets of records using SQL. In for example MySQL you can use the LIMIT and OFFSET clauses for this.

  • Dynamic parameter not bringing in all values/Pagination of dropdown values

    Hello,
    I have a dynamic (but not cascading) prompt in a Crystal 2008 SP3 report. It uses a view to bring in a list of customers.
    The underlying view returns about 1800 or so rows, but the prompt is not bringing in any more than about approx 1000 rows.
    I seem to remember this being an issue with the old Crystal reports and thought there was some kind of limitation to no more than 1000 rows unless some registry hack is performed.
    Is this still true with CR 2008 and if so, what is the correct registry setting to change this?
    Another related question (less critical than the first) -
    In my report, the prompt dropdown is "paginating" the results, so about 200 or so rows per dropdown page, with 5 pages.
    Is there a way to stop the dropdown prompt from paginating the results over multiple pages? It is awkward to have to go from page to page in the dropdown, and the filter is useful and a good workaround but wanted to know if there was a way to stop the pagination.
    Thank you

    Go to the following regsistry path
    HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 12.0\Crystal Reports\DatabaseOptions\LOV
    and add the following STRING entry (if it does not exist)
    MaxRowsetRecords
    Set the value to 2000 or whatever number you need.
    Do you retrieve the values over a universe or a direct database connection?
    Regards,
    Stratos

  • ¿iweb en mi nuevo mac ?

    estoy intentando hacer una web o blog en mi mac , lo compre pensando que seria la forma mas facil y creativa de empezar mi pagina y resulta que no encuentro ni el programa adecuado y cuando busco en google me sale el iweb pero no sale para descargar en el app store , a ver si me podeis decir que tengo q hacer?

    Google translation
    I'm trying to make a website or blog on my mac, buy it thinking it would be the easiest and most creative way to start my page and it can not find neither the right program and when I search on google I get the iweb but stays for download the app store and see if you can tell me that I q do?
    iWeb has been discontinued and not supported or offered by Apple for 2 years now.  If you need a web site application look at EverWeb. There's a demo version you can download and try.  It's user interface and drag and drop features are the most like iWeb, only with more features than iWeb. 
    For other potential iWeb replacement applications search the iWeb forum for "iWeb replacement".
    OT

  • Pagination of resultset containing few hundreds results..

    Hi,
    In my table i want to display data which is coming from the database. The resultset contains a number of rows. On my jsp page i want to display 10 rows per page. I can display data on the page but it is not doing pagination of total result in resultset.
    I am a new jsf user. And i dont know how to do this.
    Can anybody help me please...
    Thanks in advance....
    Regards,

    no, i want all rows to be printed on the page.
    But see i have approx. one million rows, so i don't want put all those rows into an arraylist.
    I dont know whether JSF has this feature or not, is there a way so that i simply return a ResultSet(which contains millions of rows) and it itself do the pagination for them.
    Or is there any other way that you think will be appropriate for me.
    Regards

  • Search result pagination loosing/doubling items

    Hi,
    my client is running Portal 10.1.2.0.2 (Build: 139) and has a custom search portlet on a page.
    It's set up to search for items of a specific custom item type in one page group only.
    When users search the results sometimes (maybe always) lacks some items and doubles some (same item shown twice).
    I am a fairly experienced Portal developer and have verified this myself.
    If I search for some word X I get 408 document hits. If the portlet is set to paginate the result at 200 hits per page I get 15 items doubled. The last 14 on page 1 (1-200) are the first 14 on page 2 (201-400). The last item on page 2 is the first on page 3 (401-408).
    Next I set pagination to 150 and search for the same word. Still 408 hits. This time 9 on the first page (1-150) showed up on the second page as well (151-300) (this time not last/first but 4 "single" items after/before the doubles). The last 12 items on page 2 was the same as the first 12 on page 3 (301-408). A total of 21 doubles.
    So I set pagination to 500 (all on one page) and serached for the word again. This time I'm unable to find any doubles.
    As the total number of hits was constant, this means that the first pagination did not show 15 items and the second pagination lost 21.
    I have searched the forums and MetaLink but found nothing.
    Has anyone heard of this before?
    Kind regards
    Tomas Albinsson
    Stockholm, Sweden

    OK, a month later...
    The same search word now gives 410 document hits (more docs have been added).
    A pagination of 200 now gives 15 doubles on page one (last 15 is the same as first 15 on page two) and one double on page two (last item is the same as first on page three).
    I set up a new custom search portlet, restricted it to just find items of a certain subtype and let the user search for text and select a year (custom attribute of the item type). Same result as the original search portlet.
    If I select another year I just get 26 docs. If pagination is set to 50 I see them all and no doubles. Changing pagination to 5 items per page produces two doubles. The last two on page 3 (items 14-15) are the same as the first two on page 4.
    Compared to the complete list I can see that items 14 and 15 are wrong, they hide two docs in those places in the complete list.
    Next I turned off the subtype restriction (ie all types are OK), leaving just search text and year for the user.
    The same search word that gave 26 above now gave 40 hits.
    A pagination of 15 was fine.
    A pagination of 10 was fine.
    A pagination of 8 gave two doubles: the last on page 3 (item 24) was the same as the first on page 4 (item 25) and the last on page 4 (item 32) was the same as the first on page 5 (item 33).
    A pagination of 24 gave one double: the last item on page 1 (item 24) was the same as the first on page 2 (item 25).
    A pagination of 23 gave two doubles: the last two on page 1 (items 22-23) was the same as the first two on page 2 (items 24-25).
    Next I turned off the year custom attribute LOV restriction, leaving only the search text (for items in one page group).
    A search for three words gave 42 hits.
    A pagination of 17 gave one double, the last item on page 1 (item 17) was the same as the first on page 2 (item 18).
    This seems fairly easy to reproduce. A custom search portlet restricted to items in a page group.
    Find search terms that give a reasonable number of hits. Set the pagination higher then the amount first, then to something that gives a few pages. The doubles seem to show up at the page "borders" (last/first on a page).
    As I have only one environment I'd be happy if someone could test this.
    Kind regards
    Tomas

  • Using Pagination, but Defaulting initial page to display all results

    Ok, I've inherited a JSF application that uses pagination to display results in a table. There's an enhancement request to initially display all the results of a table yet allow end users to "go into pagination mode." I've looked all over the web and played around with the code. Currently, I'm setting paginationbutton to true, but paginationcontrols to false. This remove the pagination navigation buttons, and initially displays all the results. Users can even go from displaying all results into pagination mode. However, the navigation is lost since paginationcontrols is set to false.
    Anybody know of a way to achieve what I'm looking for?
    Thanks,
    James

    Hi,
    When you execute any query on web, it actually uses a standard template which is present i.e. 0Analysis_Pattern and shows the report accordingly. Hence, your output will be based on the settings done in this template.
    So, I guess, you need to modify the number of rows to be visible at a time in the standard template.
    Hope this helps ..!
    -Pradnya

  • JSP Pagination with JDBC Database result

    I would like to have pagination for my JSP app. Has anyone ever done it using JDBC? What if the result is huge
    Just wondering if I get a result of 40,000 and the page would take a long time to load just to show the first few results. Should I store it in a collection and pass it on to the next page? Thanks

    We get the entire record list from the database and store it in the session. Then, use index counters to track which portion of the list to display.
    It would be cool if we could just get selected portions out of the database, but then that might mean several database.
    However, our design method makes it easy to sort the list by any column at any time.

  • Pagination or how to correctly display results

    hi all ! Im having a doubt on how to present some data in my webapp.
    The thing is that a have a 1 to N relation between objects. The way Im doing it now is that when I ask for a information I redirect to another page when a product can have several claims on it.
    The problem is that if I get for example N results the pages expands and repeats the information N times. Not good....
    Wich is the best way to present the information? Pagination? If so wich is the best source for examples or a library?
    Any ideas or suggestions are welcome.
    Thanks a lot!

    What about tabs? I have used those before to show a set of data related to a date but split over age bands, each tabl contained the data for an age band and clicking the tabs opens that set of data. Its pretty easy to do using css and divs and making the tabs clickable using javascript.

  • How not to search in the search result – reset pagination?

    I have a sql query report where I have created a text field where a use can input a search criteria, that is used in the where clause. This works perfect. But when pagination is used and you navigate to the next result set and input a new search criteria the search is only done in the displayed result set not the full data set. As far as I can figure out from other posts in this forum I have to reset the pagination when the search button is pressed. I can no figure out how to do this. People have mentioned using braches or processes or Clear Cache?. Can anybody please guide me in the right direction?
    I use version 1.6

    Well if it is setup like mine, there will be a "Branch to Page or URL" branch dependent on the "Go" button being selected.
    In this branch, immediately to the right of the "Page" to branch to, set the "reset pagination for this page".

  • Access pagination result set

    all,
    in my htmldb 1.6 application, i have a report region that displays the records from a table with pagination. i would like to write out some javascript only for the records that are displayed in the report region and not the entire contents of the table (just the 10 rows returned from the pagination).
    is there a way to access either the page variables that are passed when using pagination(so i can construct my own query to get the rows returned by the pagination) or a way to access the result set that is returned by the pagination scheme?
    paul

    Vikas,
    i have a page that i'm using to assign and remove users from oid groups. the page is split into two report regions that display sql queries, a user and a group region. on the left the user region is a paginated report that lists all the users(can be up to 6000) that also uses the htmldb_item.radiogroup control. on the right there is a group region which is a report of all the groups the user can belong to which also uses the htmldb_item.checkbox control so the administrator can select and deselect groups for the selected user.
    i'm using javascript on the user radio group to drive the group checkboxes. when an administrator selects a user record from the paginated radio group, the checkboxes next to the group they belong to in the group region becomes checked.
    to accomplish this i'm writing an after header javascript block that loops through the user sql query i used in the user region. as i loop through the user records i'm writing out javascript variables for each user that are arrays of the groups the user belongs to so i can use it to populate the group checkboxes. since the user query is paginated i want to limit my query and only write out the javascript variables for the records that are displayed on the page. so i need to know what is the max and min records displayed from the query. i can get this info from the htmldb global variables:
    wwv_flow.g_flow_current_min_row
    wwv_flow.g_flow_current_max_rows
    wwv_flow.g_flow_current_rows_fetched
    wwv_flow.g_request
    but only after the pagination controls are used. so the first time a user hits a paginated page the variables above are set to their defaults(min=1, max=10, rows fetched=0) and i have to hardcode a max value into my sql query. so i was wondering if i can somehow access it from the database/an api for that paginated region or if there is some other way to determine the record set being displayed for a paginated page.
    hope this clears it up.
    Paul

  • How do I apply pagination to webApp search results ?

    I've a search form (webapp) and I want the result to be paginated according to my css. How can I achieve this ?

    Hi,
    I found this Terminal command here on the discussion board posted bu Sinzu.
    defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnable d -bool YES
    Dimaxum
    Sorry, everyting is BOLD tekst.

  • Form pagination based on search results. Classic report

    hei folks,
    can anyone give me idea how to implement form pagination based on report search results on other page?
    and im using Classic Report.
    pagination by default gives me 1...count(rowid) number of pages
    best regards,
    Simon

    Done.
    Process Get Next or Previous Primary Key Value has a field Optional WHERE clause, you can repeat the 10 store high Where clause from your original report (on page 1). If report includes more then one table - use a view, because inside Optional WHERE clause you can only use one table/view.
    nJoy,
    Simon

  • PHP results pagination

    Hi All,
    I'm using the following script to display search results on various pages, but there are so many pages of results the list of pages takes up too much room, see;
    http://dev.merco.co.uk/node/9
    I would like the list to look more like this;
    1  2 3 ....  57 58 59 [Next] Last Page
    With dots to show there are more pages between the first and last pages.
    Any advice on how to do this would be much appreciated!
    Isabelle
    CODE START ***************************************************************************************** **************************************
    <?php
    // how many rows to show per page
    $rowsPerPage = 5;
    // by default we show first page
    $pageNum = 1;
    // if $_GET['page'] defined, use it as page number
    if(isset($_GET['page']))
        $pageNum = $_GET['page'];
    // counting the offset
    $offset = ($pageNum - 1) * $rowsPerPage;
    $user_name = "xxxx";
    $password = "xxxx";
    $database = "xxxx";
    $server = "xxxx";
    $db_handle = mysql_connect($server, $user_name, $password);
    $db_found = mysql_select_db($database, $db_handle);
    // how many rows we have in database
    $query   = "SELECT COUNT(job_title) AS numrows FROM jobs";
    $result  = mysql_query($query) or die('Error, query failed');
    $row     = mysql_fetch_array($result, MYSQL_ASSOC);
    $numrows = $row['numrows'];
    // how many pages we have when using paging?
    $maxPage = ceil($numrows/$rowsPerPage);
    // print the link to access each page
    $self = $_SERVER['PHP_SELF'];
    $nav  = '';
    for($page = 1; $page <= $maxPage; $page++)
       if ($page == $pageNum)
          $nav .= " $page "; // no need to create a link to current page
       else
          $nav .= " <a href=\"9?page=$page\">$page</a> ";
    // creating previous and next link
    // plus the link to go straight to
    // the first and last page
    if ($pageNum > 1)
       $page  = $pageNum - 1;
       $prev  = " <a href=\"9?page=$page\">[Prev]</a> ";
       $first = " <a href=\"9?page=1\">First Page</a> ";
    else
       $prev  = ''; // we're on page one, don't print previous link
       $first = ''; // nor the first page link
    if ($pageNum < $maxPage)
       $page = $pageNum + 1;
       $next = " <a href=\"9?page=$page\">[Next]</a> ";
       $last = " <a href=\"9?page=$maxPage\">Last Page</a> ";
    else
       $next = ''; // we're on the last page, don't print next link
       $last = ''; // nor the last page link
    // print the navigation link
    $nav  = '';
    for($page = 1; $page <= $maxPage; $page++)
       if ($page == $pageNum)
          $nav .= " $page "; // no need to create a link to current page
       else
          $nav .= " <a href=\"9?page=$page\">$page</a> ";
    ?>

    Hi,
    if you have the parameters in the $_GET array, which you most probably do, you can just do this:
    $myget = $_GET;
    $myget['offset'] = (insert your offset here);
    $newurl = 'http://www.mysite.com/results.php?' . http_build_query($myget);
    Also, being that this is an Oracle/PHP forum, you might have better luck asking these kinds of questions in some generic PHP forum, as your question has not much to do with Oracle itself.
    Hope this helps,
    Michal

Maybe you are looking for

  • Report on pending order qty,opening stock, and closing stock

    Any standard Report available on pending order qty against opening stock, and closing stock. Points assured Mohan

  • Strange error occurring /only/ on landscape photos

    I'm using iPhoto '11 version 9.4.3   I noticed today that a very specific set of images in one "event" are giving an error when I try to view them. All thumbnails work for every single picture. The pictures that are giving the error _do show up_ in t

  • Swing to Web

    Hi, I have a small Swing application. Can I program some JSP etc. so that the application can be accessed via web? Or is there a way to convert this small Swing app into web app? Any help is appreciated. Thanks in advance. Prashant malik

  • Samsung A501 Drawable area for Midp

    Can anyone tell me what is the drawable area of Samsung A501 (SGH-ZX20)? The screen size is 240x320. Also whenever there is a new device coming out, where can I find the information about the drawable area of the device? Any help would be great! Mess

  • SNMP alarm regarding transceivers

    Hello Community! Have this client and one of the 6509s is reporting alarms on the SNMP tool, and we are seeing the following output: SW101#sh interfaces transceiver detail Transceiver monitoring is disabled for all interfaces. mA: milliamperes, dBm: