RE: Pagination query

From: Sami Mohammed (SMOHAMME..ndependenthealth.com)
Date: Tue Mar 01 2005 - 11:06:15 EST

  • Next message: Sami Mohammed: "RE: Pagination query"

    Find attachments
    thanks sami

    CONFIDENTIALITY NOTICE. This e-mail and attachments, if any, may contain confidential information which is privileged and protected from disclosure by Federal and State
    confidentiality laws rules and regulations. This e-mail and attachments, if any, are intended for the designated addressee only. If you are not the designated addressee, you
    are hereby notified that any disclosure, copying, or distribution of this e-mail and its attachments, if any, may be unlawful and may subject you to legal consequences. If you
    have received this e-mail and attachments in error, please contact Independent Health immediately at (716) 631-3001 and delete the e-mail and its attachments from your
    computer. Thank you for your attention

    >>> "Cris Daniluk" <cris.danilu..laraview.com> 03/01/05 10:18AM >>>
    No attachment...

    > -----Original Message-----
    > From: Sami Mohammed [mailto:SMOHAMME..ndependenthealth.com]
    > Sent: Tuesday, March 01, 2005 9:57 AM
    > To: cayenne-use..bjectstyle.org
    > Subject: RE: Pagination query
    >
    > Hi
    >
    > Where i am doing wrong.
    > pls see attached files.
    >
    > thanks
    > sami
    >
    > CONFIDENTIALITY NOTICE. This e-mail and attachments, if any,
    > may contain confidential information which is privileged and
    > protected from disclosure by Federal and State
    > confidentiality laws rules and regulations. This e-mail and
    > attachments, if any, are intended for the designated
    > addressee only. If you are not the designated addressee, you
    > are hereby notified that any disclosure, copying, or
    > distribution of this e-mail and its attachments, if any, may
    > be unlawful and may subject you to legal consequences. If
    > you have received this e-mail and attachments in error,
    > please contact Independent Health immediately at (716)
    > 631-3001 and delete the e-mail and its attachments from your
    > computer. Thank you for your attention
    >
    > >>> SMOHAMME..ndependenthealth.com 02/28/05 12:33PM >>>
    > Hi
    >
    > I have still problem in paging. It retrives all the rows of
    > the table, even after setting the page size-> query.setPagesize(25).
    > i am attaching my action class , bean and jsp page.
    > whats the problem pls let me know
    >
    > thnks
    > sami
    >
    > CONFIDENTIALITY NOTICE. This e-mail and attachments, if any,
    > may contain confidential information which is privileged and
    > protected from disclosure by Federal and State
    > confidentiality laws rules and regulations. This e-mail and
    > attachments, if any, are intended for the designated
    > addressee only. If you are not the designated addressee, you
    > are hereby notified that any disclosure, copying, or
    > distribution of this e-mail and its attachments, if any, may
    > be unlawful and may subject you to legal consequences. If
    > you have received this e-mail and attachments in error,
    > please contact Independent Health immediately at (716)
    > 631-3001 and delete the e-mail and its attachments from your
    > computer. Thank you for your attention
    >
    > >>> lspoor_cayenn..otmail.com 02/23/05 01:41PM >>>
    > Hi Sami,
    >
    > You don't really need the ComplexHandler and the
    > ComplexHanderImpl. The ComplexHandler is an interface and the
    > ComplexHandlerImpl is the Cayenne implementation. You just
    > need to subclass the bean I sent. Use it like:
    >
    > // New Query (usually part of an implementation)
    > SelectQuery qry = new SelectQuery (Complex.class);
    >
    > // Set the pagesize (amount of records shown on your page)
    > qry.setPageSize(pPageSize.intValue());
    >
    > // Add some ordering
    > qry.addOrdering("code", Ordering.ASC);
    > qry.addOrdering("subcomplex", Ordering.ASC);
    >
    > // Get stuff
    > List lst = mContext.performQuery(qry);
    >
    > // This is the subclassed bean.
    > ComplexList cpxList = new ComplexList (lst,
    > pPageSize.intValue(), pCurrentRow.intValue());
    >
    > // Place the resultset in your request..
    > request.setAttribute("cpxList", cpxList.getSubSetList());
    >
    > // In your jsp using Jakarta Tag libs like:
    > <logic:iterate id="cpx" name="complexList">
    > <bean:write name="cpx" property="code"/><br/>
    > </logic:iterate>
    >
    > Regards, Laszlo
    >
    >
    >
    >
    >
    > >From: "Sami Mohammed" <SMOHAMME..ndependenthealth.com>
    > >Reply-To: cayenne-use..bjectstyle.org
    > >To: <cayenne-use..bjectstyle.org>
    > >Subject: RE: Pagination query
    > >Date: Wed, 23 Feb 2005 11:25:23 -0500
    > >
    > >
    > >Hi Laszlo,
    > >
    > >could you send me the code for ComplexHandle and ComplexHandlerImp.
    > >
    > >thanks
    > >sami
    > >
    > >CONFIDENTIALITY NOTICE. This e-mail and attachments, if any, may
    > >contain confidential information which is privileged and
    > protected from
    > >disclosure by Federal and State confidentiality laws rules and
    > >regulations. This e-mail and attachments, if any, are
    > intended for the
    > >designated addressee only. If you are not the designated addressee,
    > >you are hereby notified that any disclosure, copying, or
    > distribution
    > >of this e-mail and its attachments, if any, may be unlawful and may
    > >subject you to legal consequences. If you have received this e-mail
    > >and attachments in error, please contact Independent Health
    > immediately
    > >at (716) 631-3001 and delete the e-mail and its attachments
    > from your
    > >computer. Thank you for your attention
    > >
    > > >>> SMOHAMME..ndependenthealth.com 02/10/05 04:10PM >>>
    > >Thank you very much Laszlo.
    > >
    > >Sami
    > >
    > > >>> lspoor_cayenn..otmail.com 02/10/05 03:51PM >>>
    > >Hi Sami,
    > >
    > >Well, the bean I have provided will take a pCurrentRow as a
    > parameter,
    > >so when you (re)enter the JavaBean or Servlet responsible for
    > >retrieving the data, be sure to use next 'pCurrentrow'. This
    > >functionality is also provided in the PagedObjectList, as in
    > the method
    > >getNextSet() or getPreviousSet().
    > >
    > >Say, you use Struts, in your 'populateAction', you can use:
    > >
    > > // Retrieve Complex Subset
    > > ComplexHandler cpxh = new
    > >ComplexHandlerImpl(DataContext.getThreadDataContext());
    > > ComplexList cpxList =
    > >cpxh.getAllPaged(BackOfficeReferences.IMG_DEF_PAGE_LENGTH, newRow);
    > > request.setAttribute(ComplexList.CLASS_NAME, cpxList);
    > >
    > > // Populate pager
    > > // Previous ResultSet
    > > Boolean hasPrev = new Boolean(cpxList.hasPreviousSet());
    > > request.setAttribute("hasPrevious", hasPrev);
    > >
    > > HashMap m1 = new HashMap();
    > > m1.put("curRow", new Integer(cpxList.getPreviousSet()));
    > > request.setAttribute("prevSet", m1);
    > >
    > > // Next ResultSet
    > > Boolean hasNext = new Boolean(cpxList.hasNextSet());
    > > request.setAttribute("hasNext", hasNext);
    > >
    > > HashMap m2 = new HashMap();
    > > m2.put("curRow", new Integer(cpxList.getNextSet()));
    > > request.setAttribute("nextSet", m2);
    > >
    > > // Remember the current row.
    > > request.setAttribute("curRow", curRow == null ? "0" : curRow);
    > >
    > >Now, you can retrieve the previous and next record sets, using a
    > >construction like:
    > >
    > >..taglib uri="/tags/struts-bean" prefix="bean" %> <%@ taglib
    > >uri="/tags/struts-html" prefix="html" %> <..taglib
    > >uri="/tags/struts-logic" prefix="logic" %> <..taglib
    > >uri="/tags/struts-tiles" prefix="tiles" %>
    > >
    > ><%-- Retrieve the url needed for paging from the Tiles template --%>
    > ><tiles:useAttribute name="url" classname="java.lang.String"/>
    > >
    > ><%-- Previous --%>
    > ><logic:equal name="hasPrevious" value="true">
    > > <html:link page="<%=url%>"
    > > name="prevSet">
    > > <bean:message key="bfe.pager.previous"/>
    > > </html:link>
    > ></logic:equal>
    > >
    > ><logic:equal name="hasPrevious" value="false">
    > > <bean:message key="bfe.pager.previous"/> </logic:equal>
    > >
    > ><%-- Next --%>
    > ><logic:equal name="hasNext" value="true">
    > > <html:link page="<%=url%>"
    > > name="nextSet">
    > > <bean:message key="bfe.pager.next"/>
    > > </html:link>
    > ></logic:equal>
    > >
    > ><logic:equal name="hasNext" value="false">
    > > <bean:message key="bfe.pager.next"/> </logic:equal>
    > >
    > >
    > >Hope this helps, laszlo
    > >
    > >
    > >
    > >here you have my .jsp that
    > >
    > > >From: "Sami Mohammed" <SMOHAMME..ndependenthealth.com>
    > > >Reply-To: cayenne-use..bjectstyle.org
    > > >To: <cayenne-use..bjectstyle.org>
    > > >Subject: RE: Pagination query
    > > >Date: Thu, 10 Feb 2005 15:20:49 -0500
    > > >
    > > >Hi Laszlo,
    > > >I am also using the struts tag libs, but how can we show
    > the next and
    > > >previous pages links on the jsp.
    > > >
    > > >
    > > > >>> lspoor_cayenn..otmail.com 02/10/05 03:00PM >>>
    > > >Hi Sami,
    > > >
    > > >How you display the results on your JSP depends on what technology
    > > >you
    > >use.
    > > >I normally use Jakarta tag libraries
    > > >(http://struts.apache.org/userGuide/index.html).
    > > >
    > > >For example:
    > > >
    > > ><logic:iterate id="painting" name="ptgList">
    > > > <bean:write name="painting" property="toArtist.name"/>
    > > ></logic:iterate>
    > > >
    > > >
    > > >Regards, laszlo
    > > >
    > > >
    > > > >From: "Sami Mohammed" <SMOHAMME..ndependenthealth.com>
    > > > >Reply-To: cayenne-use..bjectstyle.org
    > > > >To: <cayenne-use..bjectstyle.org>
    > > > >Subject: RE: Pagination query
    > > > >Date: Thu, 10 Feb 2005 14:39:47 -0500
    > > > >
    > > > >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/
    > > > >
    > > >
    > > >_________________________________________________________________
    > > >MSN Search, for accurate results! http://search.msn.nl
    > > >
    > >
    > >_________________________________________________________________
    > >Talk with your online friends with MSN Messenger
    > http://messenger.msn.nl/
    > >
    >
    > _________________________________________________________________
    > Play online games with your friends with MSN Messenger
    > http://messenger.msn.nl/
    >
    >









    This archive was generated by hypermail 2.0.0 : Tue Mar 01 2005 - 11:07:16 EST