问题描述:

I'm using JBoss EAP 6.1 standalone with JSF 2.1.19 and configured my host as a virtual server at the root context. (Using a non-root context like /myApp, everything works fine). I'm trying to show FacesContext info messages after a redirect using flash scope. For some reason I am not consistently getting the Faces message to show up on the second page. Sometimes it does, sometimes not. Sometimes it shows up back on the first page.

Here is my JSF2 bean:

@ManagedBean

@RequestScoped

public class TestBean {

public String submit() {

System.out.println("...adding faces info message....");

FacesContext.getCurrentInstance().getExternalContext().getFlash().setKeepMessages(true);

FacesContext.getCurrentInstance().addMessage(null,new FacesMessage("Faces Info Message"));

return "/second/secondPage?faces-redirect=true";

}

}

Relevant firstPage.xhtml:

<h:form>

<h:commandButton value="ClickMe" action="#{testBean.submit()}"/>

</h:form>

Relevant secondPage.xhtml:

<h:body>

<h:messages id="globalMessages" globalOnly="true"/>

<h:link outcome="/firstPage" value="Back"/>

</h:body>

JBoss standalone.xml:

<subsystem xmlns="urn:jboss:domain:web:1.4" default-virtual-server="myApp" native="false">

<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>

<virtual-server name="myApp" enable-welcome-root="false" default-web-module="myApp">

<alias name="localhost"/>

</virtual-server>

</subsystem>

jboss-web.xml packaged with myApp:

<jboss-web>

<context-root>/</context-root>

<virtual-host>myApp</virtual-host>

</jboss-web>

Please help! I'm totally stumped on this one.

网友答案:

Turns out it's a bug in JBoss. FacesMessages do not properly survive a post-redirect-get when using a root context application. Filed here: https://bugzilla.redhat.com/show_bug.cgi?id=1017242

相关阅读:
Top