Typically when using DataTables you let the IDataProvider use your
dao. to return an iterator over the objects (users in this case)

When you use SortableDataProvider You need to provide an ISortState.
SingleSortState is a very basic implementation of this, you could
build your own by wrapping a map to store all the sort properties.
This ISortState is populated by the headers and must be used by your
dao to do the actual sorting.

So the iteartor of you provider would look like this
public Iterator iterator(int first, int count)
{
   return dao.findAll(first,count,getSortState()).iterator();
}

Maurice

On Fri, May 23, 2008 at 7:46 PM, David Nedrow <[EMAIL PROTECTED]> wrote:
> Assume the following...
>
> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
> @Entity
> @Table(name = "user", catalog = "blah")
> public class User implements java.io.Serializable {
>        private Long id;
>        private String name;
>
> //      getters/setters for both
> }
>
> public interface IUserDAO {
> //      public void save/delete/findAll/etc
> }
>
> public class UserDAO implements IUserDAO {
>
>        private EntityManager getEntityManager() {
>                return EntityManagerHelper.getEntityManager();
>        }
>
>        public void save(User entity) {
>                EntityManagerHelper.log("saving User instance", Level.INFO,
> null);
>                try {
>                        getEntityManager().persist(entity);
>                        EntityManagerHelper.log("save successful",
> Level.INFO, null);
>                } catch (RuntimeException re) {
>                        EntityManagerHelper.log("save failed", Level.SEVERE,
> re);
>                        throw re;
>                }
>        }
>
>        //etc
> }
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> If I want to display the Users in a table contained in a re-usable Panel(),
> should I be able to do something like...
>
> public final class UserListPanel extends Panel {
>    public UserListPanel(String id) {
>        super(id);
>
>        // Create a detachable model
>        IModel users = new LoadableDetachableModel() {
>            @SpringBean
>            UserDAO dao;
>            @Override protected Object load() {
>                return dao.findAll();
>            }
>            return users;
>        };
>
>        IColumn[] columns = { new PropertyColumn(new Model("ID"), "id"),
>                              new PropertyColumn(new Model("Name"), "name")
> };
>        SomeTableType dataTable = new SomeTableType(users);
>
>        add(dataTable);
>    }
> }
>
>
> Part of my confusion comes from trying to work in a SortableDataProvider to
> use with a DefaultDataTable with columns sortable by header (<th/>) links.
>
> -David
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

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

Reply via email to