Here's how I do it.

I have my wicket layer call a service layer, which calls a DAO.
I'm not a big fan of a lot of layers and I like to keep my projects

So, if you want a list of users on a page, for example, you can
use any of the canned wicket tables.  Those are pretty nice.
I use DefaultDataTable unless I need something special.  So in
your page class you do something like

DefaultDataTable defaultDataTable = new DefaultDataTable("table",
columnsList, new SortableUserDataProvider(userFilter), 10);

If this doesn't make sense look at the class in the
wicket examples.

In my SortableUserDataProvider, I pass in a filter obj depending on what the
is asking for.  This includes any search criteria, sort options, paging,

My SortableUserDataProvider calls my service.  That preps the hibernate
and calls my dao.

So for the SortableUserDataProvider you want to override the iterator()
something like:

public Iterator<User> iterator(int first, int count)
                SortParam sp = getSort();


                return UserService.getUsers(userFilter).iterator();

I prep my queries in my service layer.  So something like

Criteria userCriteria = session.createCriteria(User.class)
//other filter info here as needed

List<User> userList = userCriteria.list();

Hibernate returns models and lists of models, and wicket
uses models and lists of models.  

The only catch with this is your web layer is getting hibernate
aware models, not POJOs.  So if it's a closed system where nobody
else hits your hibernate code, you're fine.  If the service layer
is an SOA type arch, you'll need to convert your hibernate models
(or the list), to equivalent pojos on select and vice-versa on saves.

The only thing I did which I regret was I defined my collections 
in hibernate as Lists instead of sets.  I did this because wicket 
takes a list as a param in a lot of places and Lists are generally 
easier to work with.

But hibernate treats Lists as bags and when you are doing eager fetches
on multiple collections, Hibernate will complain.  
It won't let you fetch multiple bags simultaneously.  It used to though.
They keep threatening to fix it.

View this message in context:
Sent from the Wicket - User mailing list archive at

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to