【发布时间】:2013-07-19 11:09:45
【问题描述】:
我有两个 p:ouputPanels 具有 rendered 属性。当底层getter/setter 的值发生变化时,它们应该被渲染。但是,基础价值会以正确的顺序发生变化。第一个面板消失了,但是第二个面板没有出现。甚至不在 HTML 代码中!
我的两个面板:
<p:outputPanel id="PanelParent">
<h:form>
<p:outputPanel id="PanelForm" rendered="#{PageService.isVisibilityForm()}">
<h:commandButton value="Button"
action="#{PageService.persist}"
styleClass="btn btn-primary opal_btn submit_form_new" />
</h:form>
</p:outputPanel>
<p:outputPanel id="PanelMessage" rendered="#{PageService.isVisibilityMessage()}">
//Message
</p:outputPanel>
</p:outputPanel>
感谢你的回答!!!
-更新-
在代码中,我引用了 persist 方法,在这个方法中,我更改了每个部分的可见性的 getter 和 setter。
-UPDATE1-
好的,这实际上是我的代码:
<p:outputPanel id="parentPanel">
<p:outputPanel id="PanelForm"
rendered="#{PageService.isVisibilityForm()}">
<div>
<div>
<h:form class="homepage_invitee_form" action="" method="POST">
<p:messages id="messages" showDetail="false" autoUpdate="true"
closable="true" />
<h:inputText required="true"
value="#{PageService.instance.name}"
name="name" placeholder="Last Name"
styleClass="lastname_new" id="lastname_new"
type="text placeholder" />
<h:commandButton value="Press"
action="#{PageService.persist()}"/>
<f:ajax render="" />
</h:commandButton>
</h:form>
</div>
</div>
</p:outputPanel>
<p:outputPanel id="PanelThank"
rendered="#{PageService.isVisibilityThank()}">
<div>
Message
</div>
</p:outputPanel>
</p:outputPanel>
我真的看不出哪里失败了? ;(
【问题讨论】:
-
对不起,我想我不够清楚。条件如何评估?你在点击一个按钮吗?评估条件后如何更新页面
-
我根据一些假设发布了一个答案。您应该重写您的代码(正确关闭标签)并发布您正在做什么来更新您的客户端部分。
-
好的,我可以在我的最后重现它。给我一点时间。
-
visibilityForm按isVisibilityForm的顺序排列。 Getter 不需要get/is前缀 -
好的,Maximus 你想要答案还是我也应该重构你的代码?
标签: jsf jsf-2 primefaces