Skip to content

Instantly share code, notes, and snippets.

@lukaspili
Created May 16, 2012 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaspili/2708503 to your computer and use it in GitHub Desktop.
Save lukaspili/2708503 to your computer and use it in GitHub Desktop.
// MyController.java :
@ManagedBean
public class MyController {
private DataModel<User> dataModel;
public DataModel<User> getDataModel() {
if(dataModel == null) {
List<User> users = userService.getAll();
dataModel = new ListDataModel(users);
}
return dataModel;
}
}
// view.xhtml :
<h:datatable value="#{myController.dataModel}" var="u">
<h:column>
<f:facet name="header">
Firstname
</f:facet>
#{u.firstname}
</h:column>
<h:column>
<f:facet name="header">
Lastname
</f:facet>
#{u.lastname}
</h:column>
</h:datatable>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment