Hi, I've got a strange thing happening with jsf 2.0 where I'm using "?faces-redirect=true", just to
try and get the URL in the browser pointing to the correct page, but it's seems to be unexpectedly
creating a new session.
I've got page1.xhtml with the contents:
<h:form>
<h:commandButton value="test" action="#{backingBean.doSomething}"/>
</h:form>
Then there's the backing bean:
backingBean.java
@ManagedBean
@SessionScoped
public class backingBean {
public String doSomething() {
return "page2?faces-redirect=true";
}
With or without "?faces-redirect=true" in the return string I navigate successfully to page2.xhtml.
The problem is that in my real world application I'm setting a property in the session scoped
bean which was is no longer set when page2 is rendered. Having verified that the property was
getting set as expected, I figured that for it to not be set subsequently it must have been cleared
OR page2 was using a different session to page1.
A bit of debugging shows that the backingBean constructor is firing AFTER the property is set but
only if faces-redirect=true is set in the return navigation string.
I would expect this behaviour with a request scoped bean but not with a session bean. I'm using a
GlassFish v3 stack.
Could this be a bug or am I doing something silly? I am very new to JSF and despite having read
a lot of material I'm still very much learning the hard way.
Thanks for any help.
Brendan.