I have a misunderstanding with the use of flash scope in jsf 2. I want to put an object in flash map during my action and show this object in the next page. Here is my action (call by h:commandLink):
public String showDetail(PersonneDTO personne) {
MessageFlashBean message = new MessageFlashBean();
message.addMessage("test");
FacesContext.getCurrentInstance().getExternalContext().getFlash()
.put("test", message);
return "showDetail";
}
It's just a test, but the real object I want to use is more complex.
Here is the second page with the flash use:
<ui:fragment rendered="#{flash.test != null and flash.test.hasMessage()}" >
<ui:repeat var="message" value="#{flash.test.messages}">
#{message}
</ui:repeat>
</ui:fragment>
Here is the navigation (and here is my problem :) ):
<navigation-rule>
<from-view-id>/index.xhtml</from-view-id>
<navigation-case>
<from-outcome>showDetail</from-outcome>
<to-view-id>/private/showDetail.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
In this case, the flash scope works fine and my message appears.
But if I add a redirect in the navigation case, my object in the flash map has disappeared.
I don't understand why I can't use redirect in the navigation rule (I believed it was the goal of flash scope).
May be something is wrong in my code.
Someone can help me ?
Thanks