[jboss-user] [JBoss Seam] - Re: Seam enhanced EL expression fails in an Ajax4JSF tag

alexg79 do-not-reply at jboss.com
Mon Apr 9 19:22:54 EDT 2007


I don't know what code you want to see, but here's the bean code:

  | @Stateful
  | @Scope(ScopeType.SESSION)
  | @Name("categorybean")
  | public class CategoryBean implements CategoryLocal {
  | 
  | 	private static final int PAGE_SIZE = 30;
  | 	
  | 	@In
  | 	private EntityManager db;
  | 	
  | 	@RequestParameter
  | 	private String id;
  | 
  | 	private Category cat;
  | 	private Query entryQuery;
  | 	private int page = 0;
  | 
  | 	public Category getCategory() {
  | 		if (cat == null)
  | 			cat = db.find(Category.class, Short.parseShort(id));
  | 		return cat;
  | 	}
  | 	
  | 	@SuppressWarnings("unchecked")
  | 	public List<Entry> getEntries() {
  | 		if (entryQuery == null) {
  | 			Session session = (Session) db.getDelegate();
  | 			entryQuery = session.createFilter(getCategory().getEntries(), "");
  | 		}
  | 		
  | 		entryQuery.setFirstResult(page * PAGE_SIZE).setMaxResults(30);
  | 		return entryQuery.list();
  | 	}
  | 
  | 	public boolean isPreviousPageAvailable() {
  | 		return page > 0;
  | 	}
  | 
  | 	public boolean isNextPageAvailable() {
  | 		return page * PAGE_SIZE < getCategory().getNumEntries() - 1;
  | 	}
  | 
  | 	public void jumpPage() {
  | 		// Dummy method for jumping pages
  | 	}
  | 
  | 	public void previousPage() {
  | 		page--;
  | 	}
  | 
  | 	public void nextPage() {
  | 		page++;
  | 	}
  | 	
  | 	public int getPage() {
  | 		return page;
  | 	}
  | 
  | 	public void setPage(int page) {
  | 		this.page = page;
  | 	}
  | 	
  | 	public int[] getPageNumbers() {
  | 		int[] pageNumbers = new int[getCategory().getNumEntries()];
  | 		for (int i = 0; i < getCategory().getNumEntries(); i++)
  | 			pageNumbers = i + 1;
  | 		return pageNumbers;
  | 	}
  | 	
  | 	@Remove @Destroy
  | 	public void destroy() {}
  | 
  | }
  | 
and the local interface:

  | @Local
  | public interface CategoryLocal {
  | 
  | 	Category getCategory();
  | 
  | 	List<Entry> getEntries();
  | 
  | 	int[] getPageNumbers();
  | 	
  | 	void jumpPage();
  | 	
  | 	int getPage();
  | 
  | 	void setPage(int page);
  | 
  | 	boolean isPreviousPageAvailable();
  | 
  | 	boolean isNextPageAvailable();
  | 
  | 	void previousPage();
  | 
  | 	void nextPage();
  | 
  | 	void destroy();
  | 
  | }
  | 

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

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



More information about the jboss-user mailing list