Page numbers as like google search results

17 views
Skip to first unread message

Srini

unread,
May 21, 2008, 8:08:04 AM5/21/08
to JMesa
Hi all,

I just came across the jmesa component for pagination. Excellent
tool. I'm using jmesa taglib for evaluation. I'm having two queries.

1) Limiting options: We can limit the row fetch by using the
"limit.rowSelect.maxRows" property. Say suppose I set the value 20 for
this property while the property for
"html.toolbar.maxRowsDroplist.increments" is set as 20, the jsp page
is rendered and the first 20 rows is rendered.
My Question is when i change the property
"html.toolbar.maxRowsDroplist.increments" to 10 and if we click on
next button and it should'nt call my dao to fetch the list, since
already 20 rows are in my collections. But it is not happening. Here
is where i'm having the Questionmark

2) Paging Options: Is there is any way to include the paging icons to
display like it is available in Google Search results. Rt. now it
supports only First page,Lastpage,Previouspage and next page icon.
My question, Is there is any possiblity to have the page numbers
displayed as a button say as like n Google result page Prev < 1 2 3 4
5 6 7 8 9 > Next something like this ?

Thanks a lot in Advance

Jeff Johnston

unread,
May 21, 2008, 12:00:14 PM5/21/08
to jm...@googlegroups.com
For your first question the only way to efficiently get one page of data at a time would be to use the JMesa Limit object to effeciently retrieve one page of data at a time.

http://code.google.com/p/jmesa/wiki/LimitExample
http://code.google.com/p/jmesa/wiki/LimitTutorial

You can set the maxRows and the maxRowsIncrements, either in the preferences, or on a per-table basis. However, those settings are only for display and to tell the Limit how many rows are being requested. Also be sure that the value of the maxRows shows up in the list of the maxRowsIncrements values.

For your second question you can create your own Toolbar with the display and interaction like you want. At one point early, in the predecessor to this project, I even had that as the default, but since then have lost that code. I don't remember it being too hard though, and would be willing to work with you to do that, if you are able to do the work. I know other developers have asked for it from time to time. The key is going to be getting the Limit object and using that to know what to display.

http://code.google.com/p/jmesa/wiki/ToolbarRecipes

-Jeff Johnston

Srini

unread,
May 22, 2008, 8:29:05 AM5/22/08
to JMesa
Jeff,

Thanks for the response. Think that you dint get my question properly
or the way i read the answer might be wrong. I will put clear now hope
so :)

My requirement is say suppose I'm having 1000 records in DB and I dont
want to put the entire 1000 records in my session. Initially I need to
get the first 100 records and paginate them with 10 records/page and
if I reach the last page ie. 10th page of the 100 records it needs to
intellegently get the next 100 records.
So I thought I will be using the Jmesa Limit options. But what is
actualy happening is for each action eg. if i click on next page icon
in my JSP page the invokeAction() is called which calls my DAO and the
query is triggered. pls note for each and every action.

Pls help me out in the above issue.

And I will be very happy to work with you to enable the Toolbar which
resembles the google results page. To add to this point PagerTag lib
provides the logic for this style of pagination.

http://jsptags.com/tags/navigation/pager/pager-taglib-2.0.html#examples

I 'll start with the ground work, if you have any other inputs in this
regard pls share with me lets work together and 'll keep the jmesa
features growing.

Thanks,
--Srini


On May 21, 9:00 pm, "Jeff Johnston" <extremecompone...@gmail.com>
wrote:
> For your first question the only way to efficiently get one page of data at
> a time would be to use the JMesa Limit object to effeciently retrieve one
> page of data at a time.
>
> http://code.google.com/p/jmesa/wiki/LimitExamplehttp://code.google.com/p/jmesa/wiki/LimitTutorial
> > Thanks a lot in Advance- Hide quoted text -
>
> - Show quoted text -

Jeff Johnston

unread,
May 22, 2008, 8:50:39 AM5/22/08
to jm...@googlegroups.com

I do understand where you are coming from. However, in many environments it is not feasible to cache that much data in each users session. Over time the memory requirements would be too high. That, and I am not sure how useful that would be because that is assuming that a user is just going to the next page. With JMesa a user has the ability to sort, filter and effect the max rows. Any one of those would need to trigger getting a different result set. The most efficient thing overall would be too just keep getting one page of data with each request.

Also keep in mind though that because JMesa is an API you can easily get at the Limit and know what the user is doing. If you want to try some sort of caching strategy in the controller you can.

For the paging don't read into the requirement too far. You will need to create a toolbar item that just does some simple math. If you trace the code for one of the page toolbar items that would give you a template to use. You will not be creating new tags or doing anything that is foreign to the API. Also, unless you want you will not have to get the source code. Your custom toolbar with the custom toolbar items will just plug in....most things are plugable in JMesa as I wanted developers to add new features without having to get the source running locally :).

 -Jeff Johnston

Srini

unread,
Jun 23, 2008, 8:16:50 AM6/23/08
to JMesa
Jeff,

Had some time last week to create the CustomToolbar. Well it works
like this.

While rendering first time the results page, I'm checking the size of
the results page and based on conditoins say like more than 5 or 10
create the page numbers and after reaching the condition create the
next icon which links to the next page. Its perfectly working.

if(HtmlUtils.totalPages(getCoreContext())>5){
for (j=1; j < 6; j++) {
addToolbarItem(createCustomItem(j));
}
if(getCoreContext().getLimit().getRowSelect().getPage()<
HtmlUtils.totalPages(getCoreContext()))
addToolbarItem(createCustomItemNext(j++));

}else{
for(int i=1; i<=HtmlUtils.totalPages(getCoreContext());i++){
addToolbarItem(createCustomItem(i));
}
}

The problem is after clicking the next icon,the tag value is set as
the next page number and the results records are displayed.
But here I want to recreate the entire custom tool bar once again with
adding the new page number.

I had uploaded the CustomToolBar file in the Files section. Have a
look.

Is there is any way to call once again to create the entire custom
tool bar from the java script?
Or is there is any way to overcome the problem ?
Any other better option to overcome this one?

Jeff, Can you pls help me out to overcome this issue. I'm stuck up
with this from last week and I need to do this before Wednesday.

Regards,
Srini


On May 22, 5:50 pm, "Jeff Johnston" <extremecompone...@gmail.com>
wrote:
> >http://code.google.com/p/jmesa/wiki/LimitExamplehttp://code.google.co...
> > > - Show quoted text -- Hide quoted text -

Jeff Johnston

unread,
Jun 23, 2008, 11:40:25 AM6/23/08
to jm...@googlegroups.com
The problem is after clicking the next icon,the tag value is set as
the next page number and the results records are displayed.
But here I want to recreate the entire custom tool bar once again with
adding the new page number.

Is there is any way to call once again to create the entire custom
tool bar from the java script?
Or is there is any way to overcome the problem ?
Any other better option to overcome this one?

Could you explain this a different way? I'm not sure what you are asking. I do have your custom toolbar rendering and it seems to work fine :).

-Jeff Johnston


 

Jeff Johnston

unread,
Jun 23, 2008, 8:30:55 PM6/23/08
to JMesa

I didn't want to leave you hanging so I spent some time improving your
example. I think this is pretty good now and will be easy for me to
extract the ToolbarItem and ToolbarItemRenderer into the API so that
other developers can leverage it easily. The only thing that needs to
be more generic is the amount of page numbers you want to see at one
time. I assumed 5 for this one.

You can see the full source code here:
http://code.google.com/p/jmesa/source/browse/trunk/jmesaWeb/src/org/jmesaweb/controller/FullPaginationToolbar.java

I am also going to attach a screenshot of what it looks like as full-
pagination-toolbar.gif.

Let me know if something is not working for you!

-Jeff Johnston


On Jun 23, 10:40 am, "Jeff Johnston" <extremecompone...@gmail.com>
wrote:
> The problem is after clicking the next icon,the tag value is set as
>
> > the next page number and the results records are displayed.
> > But here I want to recreate the entire custom tool bar once again with
> > adding the new page number.
>
> > Is there is any way to call once again to create the entire custom
> > tool bar from the java script?
> > Or is there is any way to overcome the problem ?
> > Any other better option to overcome this one?
>
> Could you explain this a different way? I'm not sure what you are asking. I
> do have your custom toolbar rendering and it seems to work fine :).
>
> -Jeff Johnston
>

Jeff Johnston

unread,
Jun 23, 2008, 8:34:49 PM6/23/08
to JMesa

This is what I used for my css as well. Notice how the number that is
not a link is bolded and made a different color. Then for links it is
overridden to look normal.

.paginationItem {
font-family: verdana, arial, helvetica, sans-serif;
font-size: .9em;
font-weight: bold;
color: #c4634d;
}

.paginationItem a {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 1.0em;
font-weight: normal;
color: black;
}

-Jeff Johnston



On Jun 23, 7:30 pm, Jeff Johnston <extremecompone...@gmail.com> wrote:
> I didn't want to leave you hanging so I spent some time improving your
> example. I think this is pretty good now and will be easy for me to
> extract the ToolbarItem and ToolbarItemRenderer into the API so that
> other developers can leverage it easily. The only thing that needs to
> be more generic is the amount of page numbers you want to see at one
> time. I assumed 5 for this one.
>
> You can see the full source code here:http://code.google.com/p/jmesa/source/browse/trunk/jmesaWeb/src/org/j...

Srini

unread,
Jun 24, 2008, 3:10:31 AM6/24/08
to JMesa
Jeff,

Thanks a lot for spending some time and it works fine. I had made some
changes depending on my requirement and it gets started working.

It was wonderful working with you. Once again Thanks a lot for your
help.
Hope we meet in some other intersting discussion.

Regards,
Srini
> > > > > > > > display- Hide quoted text -
>
> - Show quoted text -...
>
> read more »

Jeff Johnston

unread,
Jun 26, 2008, 5:56:33 PM6/26/08
to JMesa

I just abstracted this out now too so that it is another type of
toolbar item! It is checked into the trunk and will be deployed the
upcoming next release (2.3.2).

To create a toolbar with the you would do this:

HtmlToolbar toolbar = new HtmlToolbar();
toolbar.enablePageItems(true);
tableFacade.setToolbar(toolbar);

In the tag you could extend the class to enable the page items and
plug it into the tag.

-Jeff Johnston
> ...
>
> read more »
Reply all
Reply to author
Forward
0 new messages