How to pass data between pages?

0

I'm trying to pass some values between pages using ManagedBeans , but it's not working:

@ManagedBean
@SessionScoped
public class Chute {
    private Boolean chutar;
    //getters e setters...
}

On the first XHTML page I have some <p:commandButton/> :

pag1.xhtml

<p:commandButton value="Chutar" action="#{Chute.setChutar(true)}" onstart="window.open('pag2.xhtml');"/>
<p:commandButton value="Passar" action="#{Chute.setChutar(false)}" onstart="window.open('pag2.xhtml');"/>

The second takes the data sent by the first one:

pag2.xhtml

<p:panel rendered="#{Chute.chutar}">
    <p:outputLabel value="Chutou!"/>
</p:panel>
<p:panel rendered="#{Chute.chutar ? false : true}">
    <p:outputLabel value="Passou!"/>
</p:panel>

The problem is when any of the buttons are clicked, pag2.xhtml appears blank. How can I solve? Are there any other approaches?

    
asked by anonymous 16.11.2014 / 16:38

1 answer

1

Try changing your commandButton to this:

<p:commandButton value="Chutar" ajax="true" oncomplete="window.open('pag2.xhtml');">
    <f:setPropertyActionListener target="#{Chute.chutar}" value="true />
</p:commandButton>

I need to test, but I do not know if it's possible to call getters and setters directly as a button action.

    
16.11.2014 / 19:50