0

I have the following scenario:

A web application (JSF) using the HttpSession provided by Spring Session (redis), this web application uses Myfaces and primefaces.

Consider this page:

<!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>

If I click the button with value "Button always rendered", everything goes fine. If I click the button with value "Click to render button", the second button with value "Button ajax rendered" is rendered, but, if I try to click the new button, then the dialog is show with no data inside.

I think that this is some kind of incompatibility between primefaces and Spring Session, because when I remove the spring session everything goes fine.

Thanks in advance.

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

There is a repo in my github with all code used (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;
    }

}
  • it could be nice to see the managed bean as well – The Bitman Apr 19 '17 at 15:11
  • @TheBitman I've added a link to the repo (with all code and configurations used). – Joao Carlos Apr 19 '17 at 18:57
  • What if you don't make the view transient? Transient="true" and viewscoped are kind of contradictory, so I think you sort of run into that the bean is not the same when submitting again. Use http://stackoverflow.com/questions/2118656/commandbutton-commandlink-ajax-action-listener-method-not-invoked-or-input-value to debug things – Kukeltje Apr 19 '17 at 19:11
  • @Kukeltje the transient was a try to remove the viewState possible problems, but with transient="true" or transient="false" the behavior is the same (in this case). I've tried to debug MyFaces, but I don't make success, the JSF tree is triggered, but doesn't reaches the managed bean. I've changed the JSF implementations from MyFaces to Mojara but the problem still happens. Debugging the primefaces command, the firebug console show equivalent posts (for both buttons). I'll look at the post and try to gather more info. – Joao Carlos Apr 19 '17 at 19:59

0 Answers0