ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brandon Goodin <brandon.goo...@gmail.com>
Subject Re: RES: PaginatedList & 'google like' results
Date Fri, 18 Mar 2005 16:15:16 GMT
If you want to abstract from the dependency on IBatis you could always
write a class that implements List as well as your own Paging
interface. Wrap the Paginated list with your class and delegate calls
to the Paginated list where needed. You would persist your wrapper
class as you would the PaginatedList.

Brandon


On Fri, 18 Mar 2005 08:06:11 -0800 (PST), Brett Gorres
<bgorres@yahoo.com> wrote:
> warning about my absolute jumping example:
> 
> (Sorry I am so chatty this week, but:)
> 
> My example only makes sense if you also have the next
> and previous links available as I did (but failed to
> mention previously).
> 
> -Brett
> 
> --- Brett Gorres <bgorres@yahoo.com> wrote:
> 
> > Leonardo:
> >
> > I succeeeded using only 1 query with PaginatedList.
> >
> > Btw unless I'm mistaken PaginatedList is tightly
> > coupled to iBATIS but that's a sacrifice of
> > portability one can make for the sake of convenient
> > paging.  If you switch from iBATIS, yes you can
> > revisit this dependency and insert different code
> > for
> > that.
> >
> > For this example code:  I had decided at the last
> > minute to add a "jumping" feature to an intranet
> > search results page that may be similar to what you
> > need.
> >
> > It is aware of only 5 possible fixed jumps.
> >
> > I allowed specific jumps within results, like so:
> > <First> | <25%> | <Middle> | <75%> | <Last>
> >
> > The JSP knows when to enable or disable the first /
> > last links.  I know I added 25%, middle and 75% to
> > what was done in JPetStore, among other things.  I
> > don't remember how much of this overlaps with that
> > example.
> >
> > Brice's parameterized approach may make more sense,
> > depending on what you need.  (I wanted fixed
> > navigation options. I think Brice and JPetStore are
> > both using a more relative approach.)
> >
> > This worked for me with a ton of search
> > results--YMMV.
> >    If you do have only a few results, maybe the
> > arithmetic could be made to be more precise.
> >
> >
> > (Snippets from my Action and some Struts/JSP example
> > code pasted in below):
> >
> >
> > // Any feedback on this is appreciated! -Brett
> > Gorres
> > // www.clevergreen.net
> >     public String doPreviousPage()
> >     {
> >         if (this.getPaginatedPatientList() != null
> >             &&
> >
> this.getPaginatedPatientList().isPreviousPageAvailable())
> >         {
> >
> > this.paginatedPatientList.previousPage();
> >             return "success";
> >         }
> >         else
> >         {
> >
> > ActionContext.getActionContext().addSimpleError(
> >                 "There were no previous results to
> > display.");
> >             return "failure";
> >         }
> >     }
> >
> >     public String doNextPage()
> >     {
> >         if (this.getPaginatedPatientList() != null
> >             &&
> >
> this.getPaginatedPatientList().isNextPageAvailable())
> >         {
> >
> > this.getPaginatedPatientList().nextPage();
> >             return "success";
> >         }
> >         else
> >         {
> >
> > ActionContext.getActionContext().addSimpleError(
> >                 "There were no more results to
> > display.");
> >             return "failure";
> >         }
> >     }
> >
> >     public String doFirstPage()
> >     {
> >         if (this.getPaginatedPatientList() != null)
> >         {
> >
> > this.getPaginatedPatientList().gotoPage(0);
> >             return "success";
> >         }
> >         else
> >         {
> >
> > ActionContext.getActionContext().addSimpleError(
> >                 "Unable to change pages as
> > requested.");
> >             return "failure";
> >         }
> >     }
> >
> >     public String doLastPage()
> >     {
> >         if (this.getPaginatedPatientList() != null)
> >         {
> >
> >
> this.getPaginatedPatientList().gotoPage(_countPages());
> >             return "success";
> >         }
> >         else
> >         {
> >
> > ActionContext.getActionContext().addSimpleError(
> >                 "Unable to change pages as
> > requested.");
> >             return "failure";
> >         }
> >     }
> >
> >     public String doJump25Percent()
> >     {
> >         if (this.getPaginatedPatientList() != null)
> >         {
> >
> >
> this.getPaginatedPatientList().gotoPage(_countPages()
> > / 4);
> >             return "success";
> >         }
> >         else
> >         {
> >
> > ActionContext.getActionContext().addSimpleError(
> >                 "Unable to change pages as
> > requested.");
> >             return "failure";
> >         }
> >     }
> >
> >     public String doJump50Percent()
> >     {
> >         if (this.getPaginatedPatientList() != null)
> >         {
> >
> >
> this.getPaginatedPatientList().gotoPage(_countPages()
> > / 2);
> >             return "success";
> >         }
> >         else
> >         {
> >
> > ActionContext.getActionContext().addSimpleError(
> >                 "Unable to change pages as
> > requested.");
> >             return "failure";
> >         }
> >     }
> >
> >     public String doJump75Percent()
> >     {
> >         if (this.getPaginatedPatientList() != null)
> >         {
> >
> > this.getPaginatedPatientList().gotoPage(3
> > * _countPages() / 4);
> >             return "success";
> >         }
> >         else
> >         {
> >
> > ActionContext.getActionContext().addSimpleError(
> >                 "Unable to change pages as
> > requested.");
> >             return "failure";
> >         }
> >     }
> >
> >     private int _countPages()
> >     {
> >         int pageCount = 0;
> >         if (this.getPaginatedPatientList() != null
> >             && this.countMatchingResults != null
> >             && this.countMatchingResults.intValue()
> > >
> > 0)
> >         {
> >             pageCount =
> >                 this.countMatchingResults.intValue()
> >                     /
> > AppConstantsInHere.PAGINATED_LIST_PAGE_SIZE;
> >         }
> >         return pageCount;
> >     }
> >
> >
> > ---------------------------------------
> > Using Struts/iBATIS PaginatedList
> > for absolute result Navigation in HTML:
> > ---------------------------------------
> >
> === message truncated ===
> 
>

Mime
View raw message