PageDAOBean.java
[...] public int countAllPages(){ Query q = em.createQuery("SELECT count(p) FROM Page p"); Number result = (Number) q.getSingleResult(); return result.intValue(); } [...]
Pages.java (a JSF helper class)
[...] public int countAll(){ return pb.countAllPages(); } [...]
pages.xhtml (JSF)
[...] <ui:fragment rendered="#{pages.countAll() == 0}" > <h:outputText value="No pages yet. Why not add a page now?" /> </ui:fragment> <ui:fragment rendered="#{pages.countAll() > 0}" > Doing now :-) </ui:fragment> [...]
I have been using this pattern on each of the list pages. If you know of a better way, feel free to let me know.
No comments:
Post a Comment