p4j5: Source For The Paginator Java EE 5 Pattern Available

I even checked in the source code sample for the Paginator pattern. Paginator is a new name for the Value List Handler Pattern from the ancient J2EE 1.4 days :-). The name Value List Handler is no more appropriate, because Paginator is also able to return persistent JPA-Entities (they do not have necessarily to be attached, or Value Object). Paginator is able to iterate over a set of entities, so it is very similar to the [GoF] Iterator-Pattern.

The usage is very straight-forward - it works like an iterator:

    CustomerQuery query = (CustomerQuery)PortableRemoteObject.narrow(remote,CustomerQuery.class);
 
      while(query.hasNext()){
            List<Customer> customers = query.next();
                System.out.println("Size: " + customers.size());
            for (Customer customer : customers) {
                System.out.println("Customer: " +customer);
            }
           
        }

The Paginator is realized as a stateful EJB 3 which works with JPA's Entity Manager. The whole source is available in p4j5.


NEW: Online Workhop Effective WebApps without Frameworks is also coming to: MUC Airport.

Airport MUC workshops: Web (SPA, PWAs, Offline, Desktop, Mobile) Applications Essentials and Effective Web Applications. No migrations. #usetheplatform

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Comments:

Very nice... I love that it implements Iterator -- should be extremely intuitive to use, and hopefully by using an interface that everyone knows of and uses every day (well, before JSE 5), it will cause people to stop and think about how these patterns can be renewed with JEE 5... Nice work!

Posted by Matt Corey on August 10, 2007 at 08:49 PM CEST #

Matt,

thanks for your nice comment. Just check it out and use it :-). I'm going to check in the remaining patterns and utilities. They are mainly abstractions and best practices from my current projects.

thanks again

Posted by Adam Bien on August 10, 2007 at 09:28 PM CEST #

Adam,

I have looked at CustomerQueryBean.java and found it to be almost generic implementation but does not use generics. Actually it has Customer specific in the return value of next() and the Query itself. The return value type could be a generics parameter of an abstract Paginator class that has an abstract getQuery method.

Posted by Istvan Verhas on June 16, 2011 at 02:20 AM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
realworldpatterns.com
...the last 150 posts
...the last 10 comments
License