JSF 2 / primefaces : p:panel not rendered with ajax?
Im not sure if this behaviour is normal or not.
Im hoping that mypanel
will be rendered only after clicking on a button that triggers an ajax
request.
Not using Ajax works 开发者_Go百科fine :
p:panel id="myPanel" rendered="#{myBean.flag}"
p:commandButton ajax="false" action="#{myBean.setFlagToTrue}"
- before clicking the button, the myPanel is not displayed
(flag = false)
- clicking the button, will set the flag to true, and myPanel is rendered fine
Using ajax fails :
p:panel id="myPanel" rendered="#{myBean.flag}"
p:commandButton ajax="true" action="#{myBean.setFlagToTrue}" update="myPanel"
- before clicking the button, the myPanel is not displayed
(flag = false)
- clicking the button, will set the flag to true (as displayed by my log file), and myPanel is not rendered
I've tried omitting the rendered attribute, and indeed the ajax works fine.
I can tell that by looking at the changes reflected inside the panel.put your panel with conditional rendering inside another and update it. Like this:
<p:outputPanel id="toUpdate">
<p:panel id="myPanel" rendered="#{myBean.flag}">
</p:panel>
<p:outputPanel>
<p:commandButton update="toUpdate"/>
This is a known issue. The element can't be updated if it doesn't exist in DOM.
精彩评论