RE: Pagination query

From: Sami Mohammed (SMOHAMME..ndependenthealth.com)
Date: Thu Feb 10 2005 - 14:39:47 EST

  • Next message: Laszlo Spoor: "RE: Pagination query"

    Hi Spoor,

    Thank you.
    How can i display the result on jsp page , if you any code that will be help ful for me.

    Thanks in advance.

    sami

    >>> lspoor_cayenn..otmail.com 02/10/05 02:25PM >>>
    Hi Sami,

    Just subclass the bean I have have attached: provided for example:

    public class ComplexList extends PagedObjectList
    {
      /**
       * Construstor
       *
       *..aram pList The list that is returned from a Cayenne Query
       *..aram pPageSize The length of the page
       *..aram pCurrentRow The current Row
       */
      public ComplexList ( List pList
                         , int pPageSize
                         , int pCurrentRow)
      {
        super(pList, pPageSize, pCurrentRow);
      } //ComplexList()

      /**
       * Constructor for unpaged list
       *..aram pList
       */
      public ComplexList (List pList)
      {
        super(pList, pList.size(), 0);
      } //ComplexList

    Usage:

          List lst = mContext.performQuery(qry);

          ComplexList cpxList = new ComplexList (lst, pPageSize, pCurrentRow);
          cpxList.getSubSetList();

    --> cpxList.getSubsetList() returns the record set. If you choose to
    instantiate the bean like:

    ComplexList cpxList = new ComplexList(lst);

    Then cpxList.getSubsetList() returns everything.

    Hope this helps, Laszlo

    >From: "Sami Mohammed" <SMOHAMME..ndependenthealth.com>
    >Reply-To: cayenne-use..bjectstyle.org
    >To: <cayenne-use..bjectstyle.org>,<cayenne-user-return-@objectstyle.org>
    >Subject: Pagination query
    >Date: Thu, 10 Feb 2005 14:02:07 -0500
    >
    >
    >Hi
    > >
    > > Thanks once again for your help.
    > > I have one proble that i have to do paginate in my
    > > webapplication. i have 2000 rows and i have to show 20
    > > rows on each page. could you send me the detail
    > > example of paginate with classes and jsp pages.
    > > i have your example below but that is not sufficant
    > > for me
    > >
    > > your tutorial example below:
    > > ---------------------
    > > import java.util.List;
    > > import java.util.Map;
    > > import org.objectstyle.cayenne.access.DataContext;
    > > import org.objectstyle.cayenne.query.SelectQuery;
    > > import org.objectstyle.art.Artist;
    > > ...
    > > DataContext ctxt;
    > >
    > > // create a query returning data rows
    > > SelectQuery q = new SelectQuery(Artist.class);
    > > q.setPageSize(50);
    > >
    > > // the fact that result is paged is transparent
    > > List artistRows = ctxt.performQuery(q);
    > >
    > >
    > > // we are reading from the first page (index < 50),
    > > // this will simply return an object
    > > Artist artist1 = (Artist)artistRows.get(3);
    > >
    > > // we are reading from the 4th page,
    > > // this will transparently resolve all objects on
    > > "Page #4"
    > > // and then return an object in question
    > > Artist artist2 = (Artist)artistRows.get(153);
    > >
    > >
    > > // This is safe and will NOT trigger a full fetch
    > > int size = artistRows.size();
    > > ...
    > > --------------------
    > > send me the jsp page where i can display 20 rows and
    > > next and previous page.
    >i need some sample example
    >
    > >
    > > thanks
    > > sami
    >
    >

    _________________________________________________________________
    Play online games with your friends with MSN Messenger
    http://messenger.msn.nl/



    This archive was generated by hypermail 2.0.0 : Thu Feb 10 2005 - 14:40:07 EST