i read many topics with problems about mojarra's flash-scope and until now, i was not able to get completly rid of these annoying
"The response was already committed by the time we tried to set the outgoing cookie for the flash. Any values stored to the flash will not be available on the next request."
messages which results in a lot of headache.
i read about workarounds like custom cookies or request-parameters, but i am not feeling very well, when such a basic thing does not work as accepted for a long time.
current enviroment:
- mojarra 2.2.13
- omnifaces 1.12.1
- tomcat 8.0.32
can anybody confirm, that this still occurs with the latest mojarra? i also had these problems with previous mojarra versions - sometimes it works, sometimes not. anyway, the message appears only one time after login, but the created cookie "csfcfc" never gets deleted and the warning now occurs on every request.
switching to myfaces is currently not an option due to other problems.
my simple case, eally nothing special?:
@ManagedBean
public class LoginBean implements Serializeable {
public String login(){
String nextPage = null;
//...
if (dataOk){
Messages.addFlashGlobalInfo("welcome");
nextPage = "/user/dashboard?faces-redirect=true";
}
return nextPage;
}
}
@ViewScoped
public class DashboardBean implements Serializeable {
@PostConstruct
protected void init(){
//....
initData();
}
}
mastertemplate.xhtml:
<h:body>
<f:view>
<div class="content">
<h:panelGroup id="messages">
<h:panelGroup layout="block" rendered="#{not empty facesContext.messageList}">
<o:messages globalOnly="true" escape="false" infoClass="alert-success alert-dismissable" />
</h:panelGroup>
</h:panelGroup>
<ui:insert name="content"/>
</div>
</f:view>
</h:body>
login.xhtml
<h:commandButton action="#{LoginBean.login}" id="btn-login" value="Login">
</h:commandButton>