-
15. Re: How do you make rich:datascroller do true pagination?
kewldude Aug 2, 2007 1:17 AM (in response to rickarcmind)All right I was able to make it work. I was also able to put a boolean variable that gets tag whenever a new query to the database needs to be done (this is to get the count(*) for the getTotalRowsCount() method). My problem right now is whenever I go through the paging...I've observed that the method getPagedDataModel() is called twice every time...that two database hits every time a page is clicked...Has anyone expereinced that? What would cause the double method call to getPagedDataModel()?
-
16. Re: How do you make rich:datascroller do true pagination?
sergeysmirnov Aug 2, 2007 2:34 AM (in response to rickarcmind)put phase tracker to your app and see when.
Most likely, once when the component tree is restored at the beginning of the lifecycle. The second time when the view is rendered at the end of it. If so, it is usual behaviour for JSF. You need to take care about caching the data during one request cycle (if you did not expect the data might be changed between the first and last phases) -
17. Re: How do you make rich:datascroller do true pagination?
kewldude Aug 2, 2007 3:37 AM (in response to rickarcmind)Yeah you're right. Lets say I have a dataTable (row to display = 10) that has 20 items in it so the scroller will have 2 pages.
First time the dataTable was diplayed the call to getPagedDataModel happens during the Render Response of the current request.
Then page 2 was clicked the getPagedDataModel was called during the Apply Request Values stage, but the call to getPagedDataModel is the same call as the previous request @ the Render Response phase (same call meaning, the call to DB contains parameters to display the 1st page of the table).
Then another call to getPagedDataModel during the Render Response phase eventually having the parameters to display the 2nd page of the table. Is this the right behavior? What about the caching of data? What class/objects do I need to play around with? -
18. Re: How do you make rich:datascroller do true pagination?
kewldude Aug 7, 2007 2:02 AM (in response to rickarcmind)^ anyone has any suggestion regarding my problem?
-
19. Re: How do you make rich:datascroller do true pagination?
ishabalov Aug 7, 2007 5:30 PM (in response to rickarcmind)You need to play with rich:dataTable with
org.ajax4jsf.model.ExtendedDataModel and org.ajax4jsf.model.SerializableDataModel
That may help you.
I has hope to put together small example of this, but it is still just a plans. -
20. Re: How do you make rich:datascroller do true pagination?
amitev Aug 7, 2007 7:11 PM (in response to rickarcmind)Igor, an example for this would be great. There are many people that want to know how to do it "the right way"
-
21. Re: How do you make rich:datascroller do true pagination?
ishabalov Aug 8, 2007 11:17 PM (in response to rickarcmind)Adrian, you can look here :-)
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4072282 -
22. Re: How do you make rich:datascroller do true pagination?
dinesh.gupta Nov 6, 2007 6:43 AM (in response to rickarcmind)Hi,
In data Iteration section, under datatable, extendedDataTable, it doesn't render amount column In IE6 but correctly displayed in Mozilla 2.0.
Any one idea about this???
Regards,
Dinesh Gupta -
23. Re: How do you make rich:datascroller do true pagination?
dinesh.gupta Nov 7, 2007 7:57 AM (in response to rickarcmind)Hi,
Please tell me how can I get currently displayed page no
and records are displaying from - to .
for example I want to display this format.
20 -24 of 2500 First previous 1|2|3|4| New |Last
can I get no of record currently displayed.
Beacuse We using Lucene so we require from & to value and page no.
Please Help me.
Reply ASAP.
Thanks in advance.
Regards
dinesh.gupta01@hotmail.com -
24. Re: How do you make rich:datascroller do true pagination?
ilya_shaikovsky Nov 8, 2007 4:23 AM (in response to rickarcmind)pageIndexVar and attribute could be used to get current page number.
-
25. Re: How do you make rich:datascroller do true pagination?
maxmustang Nov 24, 2007 3:21 PM (in response to rickarcmind)Hi all,
I found a very interesting article with example:
http://sophisticated-it.de/index.php/2007/10/09/lazy-loading-listen-bei-jsf-pagination/#more-28
Its in german but the code and solution seems be there; Ill need it too soon :-)
Max -
26. Re: How do you make rich:datascroller do true pagination?
vladimir.kovalyuk May 15, 2008 2:03 PM (in response to rickarcmind)Reference from the manual implies we could find usable example in this thread. Having read all the pages I've found just some excerpts that could be threated as something to start with not more. I'll give it a try but nevertheless I expected something simplier.
I believe rich:datascroller cannot be considered as first class component because:
1. it is not scallable at all
2. it is tied to datatable and cannot be used separately
From my perspective binding datascroller to datatable was a short-sighted decision. Generally speaking we need to navigate pages whatever they consist of. DataTable is a case but not the rule.
I think the datascroller should have been fine with two attributes: the total number of pages and the current page. That's all!
I'd suggest publishing planned changes to richfaces prior to implementing them in order to discuss pros and cons with the community (and avoid strange APIs like this or tree). And RTFM MVC for emotional posters. -
27. Re: How do you make rich:datascroller do true pagination?
bostone May 15, 2008 4:12 PM (in response to rickarcmind)Will all this insanity work with scrollableDataTable? I wasn't able successfully use extended data model with it
P.S. Mr. Rick - I do enjoy your sense of humor :) -
28. Re: How do you make rich:datascroller do true pagination?
ngotau1989 Jun 24, 2011 3:04 AM (in response to rickarcmind)calm down guys
ok, let do it in asian way.
The principle is simple.
View layer catch paging event, send page number to the controller.
<f:facet name="footer">
<rich:dataScroller page="#{searchUserAction.page}"/>
</f:facet>
Controller now has page number, pageSize already defined. So it knows the range of records to load from database.
public String search(){
userSearchCondition.setStart((page-1) * userSearchCondition.getPageSize());
SearchResult<User> searchResult = userService.search(userSearchCondition);
users = new ArrayList<UserAdapter>();
for(User user : searchResult.getRows()){
users.add(new UserAdapter(user));
}
users = new ResultList<UserAdapter>(users, searchResult.getTotalRow(), userSearchCondition.getPageSize());
return "success";
}
public void setPage(int page) {
this.page = page;
search();
}
and here's the trick
public class ResultList<T> extends AbstractList<T> {
private final List<T> rows;
private final int total;
private int pageSize;
public ResultList(List<T> rows, int total, int pageSize){
this.pageSize = pageSize;
this.rows = rows;
this.total = total;
}
@Override
public T get(int index) {
index = index%pageSize;
return rows.get(index);
}
@Override
public int size() {
return total;
}
}
-
29. Re: How do you make rich:datascroller do true pagination?
itoito Sep 7, 2011 9:34 AM (in response to ngotau1989)Hi, I had the same problem last week and I think a different solution only with RichFaces.
- First I load the 10 first records by Java in a List
- Then, I do a COUNT of ALL the records.
- I load the rest of the List with the same empty Object as to the total; they are pointing to the same empty Object, no cost os memory.
- Then I have the paginator done.
<rich:datascroller page="#{myBean.pageNumber}" for="tableId"> - In myBean, on the method "setPageNumber", I load the data for this page and replace the empty Object with the Data Base Object, showing it in the table.
PROS of this method:
- It´s Simple
- It´s clear
- No more jar
- Pages cached (I have a page in memory if I return to this page)
Thanks for your ideas