I'm trying to pass an object while redirecting between View1 to View2, using JSF and Primefaces.
I'm using JSF Flash scope to do so,The object do pass to the second view but I'm still getting this warnning:
com.sun.faces.context.flash.ELFlash setCookie
WARNING: JSF1095: 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.
and the flash cookie is not deleted even after few more redirects.
View1.xhtml
<ui:composition xmlns=...... template="../../../BaseTemplate.xhtml">
<ui:define name="templateContent">
<mm:MyComponent />
</ui:define>
</ui:composition>
MyComponent.xhtml
<html xmlns= ......>
<composite:interface componentType="usersListComponent">
</composite:interface>
<composite:implementation>
<h:form>
<p:commandButton action="#{cc.passObject}" value="passMyObject" />
</h:form>
</composite:implementation>
</html>
MyComponent.java
@FacesComponent("myComponent")
public class MyComponent extends UIComponentBase {
private MyObject objectToPass;
public String passObject() {
ExternalContext externalContext= FacesContext.getCurrentInstance().getExternalContext();
externalContext.getFlash().put("objectToPass", objectToPass);
return "View2";
}
}
View2Controller.java
@ManagedBean
@ViewScoped
public class View2Controller implements Serializable {
@PostConstruct
public void init() {
MyObject ob = (MyObject) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("objectToPass");
......Do Something with MyObject
}
}
SOLVED!!!!!!
I'm not sure this is the best way but it worked for me..
The problem is in the http buffer size and jsf lifecycle, the cookies are written after the response is written and the buffer is to small to contain them both.
I'm not sure this is the best way but it worked for me..
The problem is in the http buffer size and jsf lifecycle, the cookies are written after the response is written and the buffer is to small to contain them both.