我有以下情况:
使用Spring Session(redis)提供的HttpSession的Web应用程序(JSF),这个Web应用程序使用Myfaces和primefaces。
请考虑以下页面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<f:view transient="true">
<h:head>
</h:head>
<h:body>
<h:form>
<p:commandLink actionListener="#{mainMB.enableButton}" update="pnl1" value="Click to render button" />
<h:panelGroup id="pnl1" layout="block">
<p:commandButton value="not working" actionListener="#{mainMB.process}"
oncomplete="PF('dlgNome').show();" rendered="#{mainMB.shouldRenderButton}"/>
</h:panelGroup>
<h:panelGroup id="pnl2" layout="block">
<p:commandButton value="working" actionListener="#{mainMB.process}"
update="dlgNome" oncomplete="PF('dlgNome').show();" />
</h:panelGroup>
<p:dialog id="dlgNome" widgetVar="dlgNome" header="Nome">
<h:panelGroup id="pnlNome">
<h:outputText value="#{mainMB.nome}" />
</h:panelGroup>
</p:dialog>
</h:form>
</h:body>
</f:view>
</html>
如果我点击“按钮始终呈现”的按钮,一切都很顺利。 如果我单击带有“Click to render button”值的按钮,将呈现值为“Button ajax rendered”的第二个按钮,但是,如果我尝试单击新按钮,则显示对话框,其中没有数据。
我认为这是primefaces和Spring Session之间的某种不兼容性,因为当我删除spring会话时一切都很顺利。
提前致谢。
MyFaces: 2.2.12
Spring: 4.3.7.RELEASE
Spring Session: 1.3.0.RELEASE
Spring Session (data - redis): 1.3.0.RELEASE
Lettuce: 3.5.0.Final
Primefaces: 6.0
我的github中有一个使用所有代码的回购(https://github.com/joaocarlos86/spring-session-problem)
MainMB
package br.com.jsf;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
@ManagedBean
@ViewScoped
public class MainMB implements Serializable{
private static final long serialVersionUID = -637131500663021232L;
private String nome;
private Boolean shouldRenderButton;
public void process(){
this.setNome("This is a name, and this is a number: ".concat(String.valueOf(Math.random())));
}
public void enableButton(){
this.shouldRenderButton = Boolean.TRUE;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public Boolean getShouldRenderButton() {
return shouldRenderButton;
}
public void setShouldRenderButton(Boolean shouldRenderButton) {
this.shouldRenderButton = shouldRenderButton;
}
}