I'm having troubles with view scoped bean. I have commandbutton in xhtml, with associated action in managed bean which is supposed to render the same view again. Action method returns fine, but no view is rendered, it's stuck with "waiting for localhost" message in browser. For some reason bean's @PreDestroy method and @PostConstruct methods of ejb injected in it are called multiple times ( it seems infinetely). If I change the bean to Sessionscoped, everything works fine. I'm using netbeans 7.2.1, working on web application with added JSF framework.
xhtml part:
<h:form id="getmovie" >
<h:panelGrid id="movienameform" columns="3" rendered="#{!MovieBean.choseMovie}">
<h:outputLabel for="moviename" value="Movie name: "/>
<h:inputText id="moviename" value="#{MovieBean.name}"/>
<h:commandButton value="submit" action="#{MovieBean.checkMovieExists()}">
</h:commandButton>
</h:panelGrid>
</h:form>
backing bean:
@Named(value = "MovieBean")
@ViewScoped
public class MovieBean implements Serializable {
private String name;
private boolean exist;
private boolean searched = false;
private boolean choseMovie = false;
@EJB
MovieejbLocal movieejb;
ScreenejbLocal screenejb;
public String checkMovieExists() {
setExist(getMovieejb().checkMovieExists(getName()));
searched = true;
return null;
}
...
}
and ejb
@Stateful
@Local(MovieejbLocal.class)
public class Movieejb implements MovieejbLocal {
....
}
I need this bean to be view scoped and not session scoped. Any ideas what is wrong with viewScoped here?
I've seen this question: @ViewScoped Managed bean loads many times during postback, but solution there doesn't work for me.
Thanks!