[jboss-user] [JBoss Seam] - Re: Paginator EJB and DataModel

monkeyden do-not-reply at jboss.com
Fri Oct 6 16:07:40 EDT 2006


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 action
public 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);
  | ...
  | }

Paginator

  | public 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);
  |     }
  | }

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976679#3976679

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976679



More information about the jboss-user mailing list