Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Value List Handler Pattern

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My web application must display a large number of records from a table in a relational database - by large I mean the table has approx. 1,000,000 rows and searches could return 1000's of records. Clearly, I can't do this with EJB finder methods, so I have opted to implement the Value List Handler pattern so that the client only ever has a page or two of results at a time. So far this hasn't been a problem, and I think it will be the ideal solution. Now, when I am displaying the table of records on a web page I would like to use some pre-existing tags to make things easier (specifically displaytag.sourceforge.net ). To use these tags you simply pass them a List or Iterator and they take care of the rest. Now the problem is that when implementing the Value List Handler pattern the client will get one page of results at a time, and if I simply pass this one page (usually a List) to the custom tags, the tag library will think that the one page represents all of the results and only allow the user to scroll through the one set. Hope this makes sense so far. Now my solution has been to write an Iterator, which exists at the client level, and under the hood it keeps grabbing new pages from the server and makes it look like one collection to the client. Does these seem like a reasonable solution? Problem I have had, is that when the page first loads (ie. displaying page 1) the tag library just keeps calling hasNext() on my iterator to figure out the size of the underlying collection. This defeats the whole purpose because my iterator will in-turn keep grabbing pages from the server. Any and all ideas are welcome. Thanks in advance.
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to understand your question. Each ValueList aggregates ValueObjects, so you're using logic:iterate or similar to iterate through the valuelist correct? Since there is only 1 ValueList to be iterated through per page I can't follow why you're iterating through anything else?

Usually "Back" and "Next" links on the page should have a parameter that passes the verb so that you can execute getPreviousElements() or getNextElements() as the case may be
 
Steve Ford
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for you response Kevin. I guess when I think about it my problem is not really with the ValueListHandler or any other EJB tier component, but more with the custom tags (displaytag.sourceforge.net ) that I am trying to use to display the rows. With this tag Library you don't have to use logic:iterate, as you suggest, to display each row. All you have to do is pass the tag a List of DTO's or beans, and the library will take care of displaying the rows in a table along with the "Back" and "Next" links which are generated automatically. You just specify how many rows you want displayed per page. The problem is that if I pass the tag one ValueList the tag library will think the list represents the "whole" set of data. For example, lets say that a call to getNextElements() returns a ValueList of 100 elements and I pass that List to the custom tags and specify 10 rows per page. The page will only allow you to scroll through 10 pages (10 rows x 10 pages = 100 elements in ValueList) or the whole ValueList, and I will have no opportunity to call getNextElements() again. To overcome this, I tried to create my own implementation of iterator which I could pass to the custom tag (the tag will take lists, iterators, etc.) My iterator would cache an internal copy of a ValueList and allow the user to keep calling next() to retrieve ValueObjects. When the ValueList was empty, the iterator would make another call to getNextElements() to retrieve a new ValueList. This would allow the user of the iterator to keep calling next() until they actually got all the DTO's or beans for each record in the underlying table. In hindsight, I think this has become too complicated, and maybe the best approach will be to abandon the custom tag library and just output the results table using standard tags. Hope this all makes sense. What do you think?

[ September 15, 2005: Message edited by: Steve Ford ]
[ September 15, 2005: Message edited by: Steve Ford ]
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had the same problem, and finally decided to not use the custom tag. Another problem was related with the sorting by columns functionality, witch was not well suited for this case.

-------------------------------
Giblerto
villas pollensa
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic