My trouble is that I need to refresh the list when I return from nested conversation
into parent conversation context
, and I cannot find the way to do it. I try the following. .
I have Factory-bean(DataTableFactory), Home-bean(MovieHome) and two pages(page1.xhtml and page2.xhtml).
My DataTableFactory class have factory method:
@Factory("movies", scope = ScopeType.CONVERSATION)
public List<Movie> getMovies() {
return em.createQuery("select movie from Movie movie").getResultList();
}page1.xhtml contains
<h:dataTable var="item" value="#{movies}"><s:link value="Create new movie" action="#{home.movie.beforeNew}"/>@Name("home.movie")
public class MovieHome extends EntityHome<Movie> {
...
public void beforeNew() {
clearInstance();
info("conversation.id = #{conversation.id}, movies = #0", Contexts.getConversationContext().get("movies"));
Contexts.getConversationContext().remove("movies");
info("movies = #0", Contexts.getConversationContext().get("movies"));
Conversation.instance().beginNested();
return "/page2.xhtml";
}
...
}
and I get the following log:
conversation.id = 6, movies (before remove) = [Movie(...) ...]
movies (after remove) = null
Later, when page2.xhtml is rendered I have nested conversation with number 8. On debug.seam page I select parent conversation (with number 6) and see than movies remained in context !
Of course when I return to page.xhtml the value of the movies variable remained in the parent context and the list is not refreshed (-:
But if I do not start the nested conversation, movies is removed from context.