Skip to content

Instantly share code, notes, and snippets.

@nazartm
Created February 3, 2013 18:50
Show Gist options
  • Save nazartm/4703114 to your computer and use it in GitHub Desktop.
Save nazartm/4703114 to your computer and use it in GitHub Desktop.
Simple datatable in JSF with a managed bean.
<h:dataTable value="#{myBean.books}" var="book">
<h:column>
<f:facet name="header">Title</f:facet>
#{book.title}
</h:column>
<h:column>
<f:facet name="header">Author</f:facet>
#{book.author}
</h:column>
<h:column>
<f:facet name="header">Released</f:facet>
<h:outputText value="#{book.releaseDate}" >
<f:convertDateTime dateStyle="medium" />
</h:outputText>
</h:column>
</h:dataTable>
@ManagedBean
@RequestScoped
public class MyBean {
private List<Book> books;
@PostConstruct
public void init() {
//retrieve books.
}
public List<Book> getBooks() {
return books;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment