Can I get value of DataTable in JSF from method that will return a list of objects instead of getting from getter of an attribute?
FilmBean.java
@ManagedBean(name = "filmBean")
@SessionScoped
public class FilmBean
{
private List<Film> filmList;
private final Helper helper;
public FilmBean()
{
helper = new Helper();
}
@PostConstruct
public void init()
{
filmList = helper.getFilmTitles(0, 100);
}
public List getFilmTitles()
{
return helper.getFilmTitles(0, 100);
}
public List getFilmList()
{
return filmList;
}
}
jsf.xhtml
<h:body>
<h:dataTable value = "#{filmBean.filmList}" var = "film">
<h:column>
<f:facet name = "header">Film Title</f:facet>
#{film.title}
</h:column>
<h:column>
<f:facet name = "header">Release Year</f:facet>
#{film.releaseYear}
</h:column>
</h:dataTable>
</h:body>
The code above works perfectly until I change value = "#{filmBean.filmList}"
to value = "#{filmBean.getFilmTitles()}"
I will get error:
org.hibernate.TransactionException: nested transactions not supported
But they are both return the list, why is this happen? It looks like it calls the method several time.