This content has been marked as final.
Show 2 replies
-
1. Re: Paginator EJB and DataModel
monkeyden Oct 6, 2006 4:07 PM (in response to monkeyden)Gavin,
I extended your ListDataModel for this and used @Out instead of @DataModel. My extension provides the methods used for pagination and sorting and, in doing so, attempts to manipulate the super classes attributes (rowCount, rowIndex and wrappedData). The exception I'm getting is:
attempted to bind an Out attribute of the wrong type to: userSearchAction.paginator
Everything works fine up until Seam attempts to outject it. Maybe I'm misunderstanding how your code works. Is it not simply outjected as a ListDataModel?
Here is the relevant code:
My Seam actionpublic class UserSearchAction implements UserSearch @Out(required=false) private ListDataModelPaginator paginator; ... Query query = em.createQuery(query); paginator = new ListDataModelPaginator(query.getResultList()); paginator.sort(ASC_NAME_COMPARATOR); ... }
Paginatorpublic class ListDataModelPaginator extends ListDataModel { private int rowsPerPage = 20; public ListDataModelPaginator() { super(new ArrayList()); } public ListDataModelPaginator(List list) { super(list); } public ListDataModelPaginator(List list, Comparator comp) { super(list); } public void scrollFirst() { setRowIndex(0); } public void scrollPrevious() { setRowIndex(getRowIndex()-rowsPerPage); if (getRowIndex() < 0) { setRowIndex(0); } } public void scrollNext() { setRowIndex(getRowIndex()+rowsPerPage); if (getRowIndex() >= getRowCount()) { setRowIndex(getRowCount() - rowsPerPage); if (getRowIndex() < 0) { setRowIndex(0); } } } public void scrollLast() { setRowIndex(getRowCount() - rowsPerPage); if (getRowIndex() < 0) { setRowIndex(0); } } public boolean getIsScrollFirstDisabled() { return getRowIndex() == 0; } public boolean getIsScrollLastDisabled() { return getRowIndex() >= getRowCount() - rowsPerPage; } public boolean getIsScrollNextDisabled() { return getRowIndex() >= getRowCount() - rowsPerPage; } public boolean getIsScrollPreviousDisabled() { return getRowIndex() == 0; } public int getRowsPerPage() { return rowsPerPage; } public void setRowsPerPage(int rowsPerPage) { this.rowsPerPage = rowsPerPage; } public void setSortedList(List items){ super.setWrappedData(items); super.setRowIndex(0); } public void sort(Comparator comp){ List unsorted = (List)getWrappedData(); Collections.sort(unsorted, comp); super.setWrappedData(unsorted); super.setRowIndex(0); } }
-
2. Re: Paginator EJB and DataModel
gavin.king Oct 6, 2006 7:41 PM (in response to monkeyden)Looks like you have a Seam component called "paginator" floating around somewhere in your project. Remove it.