-
1. Re: pagination problem, advice needed
gavin.king Jan 24, 2007 3:51 PM (in response to liudan2005)t:dataScroller is absolutely the wrong way to do it - as you've noticed, it means loading a massive result set into memory just to display a few items. I've seen lots of JSF controls like this - written by people who think too much about the GUI and not enough about data access. This is a major problem in the web framework space. One of the reasons Seam is so different to other web frameworks is that we took all our Hibernate experience into account when designing it.
So, the way to do it in Seam is to use Query pagination. Check out the contactlist example, and this documentation:
http://docs.jboss.com/seam/1.1BETA2/reference/en/html/framework.html#d0e6595 -
2. Re: pagination problem, advice needed
liudan2005 Jan 24, 2007 6:05 PM (in response to liudan2005)Thanks Gavin. I've had a look at Query and it looks great. However, my situation is a bit more complicated. What I need is a way to to paginating the collocation based property of my entities. Here is my code:
<h:dataTable value="#{persons}" var="person" > <h:outputText value="#{person.name}" /> <h:outputText value="#{person.age}" /> <h:dataTable value="#{person.reviews}" var="review" > <h:outputText value="#{review.title}" /> </h:dataTable> <h:dataTable value="#{person.calls}" var="call" > <h:outputText value="#{call.duration}" /> </h:dataTable> <h:dataTable>
As you can see, Query is good for paginating #{persons}. But for #{person.reviews}, I don't see a easy way of doing it. I have many entities that require this kind of multi-level pagination. Can you give any advices on this? Thanks -
3. Re: pagination problem, advice needed
gavin.king Jan 24, 2007 6:40 PM (in response to liudan2005)You want to paginate a table inside another table???!
I have never seen this done in any user interface in my life.
Sounds like a bad idea.
Anyway, I'm sure you could very easily do this by following the patterns used in the Query class. -
4. Re: pagination problem, advice needed
liudan2005 Jan 26, 2007 11:31 AM (in response to liudan2005)Sorry I was trying to explain my situation better but made it worse. Here is my scenario. The person.xhtml page shows all the properties of Person entity. In this page, I need to show top 5 records of person's calls and reviews. Here is the code:
<h:outputText value="#{person.name}" /> <h:outputText value="#{person.age}" /> <h:dataTable value="#{person.reviews}" var="review" > <h:outputText value="#{review.title}" /> </h:dataTable> <h:dataTable value="#{person.calls}" var="call" > <h:outputText value="#{call.duration}" /> </h:dataTable>
Paginating for {person} is easy when using Query. but to paginating for {person.reviews} and {person.calls} is not easy. By now, I have to create a pagination object for each collection based property. If Person has 4 collection type properties (e.g. calls,reviews...), I basically have to create 4 extra pagination objects with customised Hsqls for pagination. It's so time consuming to do it this way. If I use t:dataScroller, I wouldn't have to create those 4 extra objects. But as you said, there's performance problem with t:dataScroller. It would be nice if Seam can provide a s:dataScroller, which support real database based pagination.