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 page XHTML 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:
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 one of the buttons is clicked, the pag2.xhtml appears blank.
How can I solve? There are other approaches?
Try to change
onstart
foroncomplete
. The problem is that it is opening the new window before theaction
be completed.– Wakim
@Wakim, it was the same. The Managedbean needs a builder?
– ptkato
If the page is empty, there may be an error in your XHTML file and JSF cannot render the page.
– Renato Dinhani
If I put
rendered="true"
or simply remove the attribute, the panel appears.– ptkato
Just exchange the rendered for
#{not Chute.chutar}
or#{! Chute.chutar}
that works.– Wakim
Did you give any exceptions (in the log’s)? Type one
NullPoiterException
for the attributechutar
?– Cold
It’s all clear, no exceptions.
– ptkato
Like the panels of
pag2.xhtml
You know whose session it is? I mean, isn’t he getting an empty session? For there is nothing saying it is to catch the object on which the value was assigned inpag1.xhtml
.– ptkato