0

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!

Community
  • 1
  • 1
qwerty
  • 175
  • 4
  • 15
  • Which JSF implementation are you using? – Aritz Sep 20 '13 at 12:19
  • Sorry, I'm not sure I totally understand your question. In the frameworks of the project I see JSF 2.1 as server library (there's no choosing option there) – qwerty Sep 20 '13 at 13:08
  • There's a problem with `@ViewScoped` and some Mojarra implementations with tons of questions here in SO. It's related with a chicken-egg issue mention in the link you posted. Tried out with a basic example and works (Mojarra jsf 2.1.26 for me). – Aritz Sep 20 '13 at 13:23
  • How can I see the exact jsf version in netbeans? I can't find anything besides JSF 2.1 in the frameworks of the project. – qwerty Sep 22 '13 at 11:08

0 Answers0