code_junkie

Iterate over HashMap.values() in JSF+Facelets

Nov 12th, 2011
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. private Map<String, Document> documents = new HashMap<String, Document>();
  2.  
  3. public Collection<Document> getDocuments(){
  4. return documents.values();
  5. }
  6.  
  7. <h:dataTable id="documentTable"
  8. value="#{DocumentManager.allDocuments}"
  9. var="doc" rowClasses="list-row-odd, list-row-even"
  10. headerClass="table-header" styleClass="bordered">
  11.  
  12. <h:column id="col_name">
  13. <f:facet name="header">Name</f:facet>
  14. ${doc.name}
  15. </h:column>
  16. </h:dataTable>
  17.  
  18. public List<Document> getDocuments(){
  19. List<Document> rtrn = new ArrayList<Document>();
  20. for(Document doc : documents.values())
  21. rtrn.add(doc);
  22. return rtrn;
  23. }
Add Comment
Please, Sign In to add comment