在JSF Primefaces中重新加载页面后保存复选框状态

在JSF Primefaces中重新加载页面后保存复选框状态,primefaces,jsf-2.2,Primefaces,Jsf 2.2,我使用primefaces 5中的“DataTable-Selection”()来检查所选行,但是当我重新加载页面时,复选框被取消选中,如何在会话中保持复选框的状态 ** *********数据表**************** ** Votar产品箱 #{v.nombre} 这是设置会话变量的方式: FacesContext facesContext = FacesContext.getCurrentInstance(); HttpSession session = (HttpSession

我使用primefaces 5中的“DataTable-Selection”()来检查所选行,但是当我重新加载页面时,复选框被取消选中,如何在会话中保持复选框的状态

**

*********数据表****************

**


Votar产品箱
#{v.nombre}

这是设置会话变量的方式:

FacesContext facesContext = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(true);
session.setAttribute("foo", "bar");
以下是获取会话变量的方法:

FacesContext facesContext = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(false);
Enumeration e = session.getAttributeNames();
while (e.hasMoreElements())
{
  String attr = (String)e.nextElement();
  System.err.println("      attr  = "+ attr);
  Object value = session.getValue(attr);
  System.err.println("      value = "+ value);
}

您唯一的任务是将复选框的状态保存到会话中,然后将其加载。

我通过安装较新版本的Primefaces 5.2解决了这个问题,我有5.1版本,它也有这个错误。

尝试了较新版本的PF?我记得这是很久以前的一个issie。很好,现在可以用了。一个5.1.x版本会有所帮助(但这需要花钱)。因此,下次,请进行更多调查(查看PF中已解决的问题,例如,并立即尝试更新版本)
FacesContext facesContext = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(false);
Enumeration e = session.getAttributeNames();
while (e.hasMoreElements())
{
  String attr = (String)e.nextElement();
  System.err.println("      attr  = "+ attr);
  Object value = session.getValue(attr);
  System.err.println("      value = "+ value);
}