rich:dataScroller on rich:dataTable gives warning JSF1095
p_kris Sep 9, 2011 5:00 PMHi all,
I have a h:commandLink
inside rich:dataTable
with rich:dataScroller
in the footer. When I click on the command link, I'm adding a FacesMessage to the context and redirecting to the same page. I have a h:messages tag on the page to display any faces messages. I am able to display the message, but I'm getting following warning and the messages are not getting cleared.
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.
If I remove the rich:dataScroller
from the footer and replace rich:dataTable
with rich:dataScroller
, then I don't get any warnings and everythings works as expected.
I am using JSF2.0 (Mojarra 2.1.3), RF4.0.0.Final. Following is the code
index.xhtml
{code:xml}
<rich:panel header="Data table test">
<rich:dataTable id="dTable" value="#{myBean.allInventory}" var="inv" style="margin: auto; width: 100%; min-width: 750px;"
rows="10" >
<rich:column>
<h:outputText value="#{inv.slno}" />
</rich:column>
<rich:column>
<h:commandLink id="docMessage" title="Click for details" action="#{myBean.cLink(inv)}" value="#{inv.item1}"/>
</rich:column>
<rich:column>
<h:outputText value="#{inv.item2}" />
</rich:column>
<f:facet name="footer">
<rich:dataScroller id="dataScroll" for="dTable"/>
</f:facet>
</rich:dataTable>
<h:messages id="messages" globalOnly="true" layout="table" />
{code}
MyBean.java
{code}
package com.mypkg;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.SessionScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.inject.Named;
@Named
@SessionScoped
public class MyBean implements Serializable {
private List<Inventory> allInventory = null;
public List<Inventory> getAllInventory() {
if (allInventory == null) {
allInventory = new ArrayList<Inventory>();
for (int i = 0; i < 100; i++) {
Inventory e = new Inventory();
e.setSlno(i + 1);
e.setItem1("Item1" + Math.random());
e.setItem2("Item2" + Math.random());
allInventory.add(e);
}
}
return allInventory;
}
public String cLink(Inventory inv) {
FacesContext.getCurrentInstance().getExternalContext().getFlash().setKeepMessages(true);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Sample Error Message", "Sample Error Message"));
return "index?faces-redirect=true";
}
}
{code}
Inventory.java
{code}
package com.mypkg;
public class Inventory {
private int slno;
private String item1;
private String item2;
public int getSlno() {
return slno;
}
public void setSlno(int slno) {
this.slno = slno;
}
public String getItem1() {
return item1;
}
public void setItem1(String item1) {
this.item1 = item1;
}
public String getItem2() {
return item2;
}
public void setItem2(String item2) {
this.item2 = item2;
}
}
{code}
You can find more details about the issue here
Why does adding rich:dataScroller
on rich:dataTable
causes JSF1095 warning?
Thanks