渲染的属性不会在后续 ajax 调用中更新
我有一个 p:commandButton
调用视图范围的 bean 方法。该方法设置两个名为 textA 和 textB
的字符串字段,然后返回。
ajax 调用完成后,将显示该对话框。我希望根据变量 choice
仅显示一个网格。它的初始值为choiceA
。发生的情况是,页面加载默认选项 A,我单击按钮,actionListener 方法设置 textA
并且对话框显示。正如预期的那样,只有一个网格。
但是,当我选择 choiceB 时,显示的仍然是相同的网格 gridA
。换句话说,p:panelGrid
的 rendered
属性仅在页面加载时正确运行,但不会在后续 ajax 调用中更新。奇怪的是,textA 和 textB
更新得很好。
以下是代码的相关部分。
<h:form>
<p:selectOneRadio id="optionChoice" value="#{bean.choice}"
<f:selectItem itemLabel="B" itemValue="choiceB" />
<f:selectItem itemLabel="A" itemValue="choiceA" />
</p:selectOneRadio>
<p:commandButton value="Save"
actionListener="#{bean.save}"
update="dialogId"
oncomplete="ajaxComplete(xhr, status, args)">
</h:form>
...
<p:dialog widgetVar="dialog" id="dialogId">
<p:tabView id="tabViewX">
<p:tab id="tabA" title="Tab A">
<h:panelGrid id="gridA" rendered="#{bean.choice eq 'choiceA'}">
<p:inputTextarea value="#{bean.textA}" />
<h:button />
</h:panelGrid>
<h:panelGrid id="gridB" rendered="#{bean.choice eq 'choiceB'}">
<p:inputTextarea value="#{bean.textB}" />
</h:panelGrid>
</p:tab>
</p:tabView>
</p:dialog>
有什么建议为什么p:commandButton
的update
属性只更新inputTextArea的值
而不更新panelGrid的渲染
吗?
我也尝试过 update="tabViewX:gridA tabViewX:gridB"
。也不工作。
JSF 版本:Mojarra JSF API (javax.faces/2.1) 2.1.5 (20111123-SNAPSHOT)。 Primefaces 3.0.0 – Murat 2 分钟前编辑
I have a p:commandButton
that calls a view-scoped bean method. The method sets two string fields called textA and textB
, and returns.
Once the ajax call completes, the dialog shows up. I expect only one of the grids to show up based on the variable choice
. It's initial value is choiceA
. What happens is, the page loads with default choice A, I click the button, actionListener method sets textA
and the dialog shows up. There is only one grid, as expected.
However, when I choose choiceB, it's still the same grid, gridA
, that's displayed. In other words, the rendered
attribute of the p:panelGrid
s is only functioning correctly at page load, but is not updating on subsequent ajax calls. Strangely, textA and textB
are updating well.
Below is the relevant part of the code.
<h:form>
<p:selectOneRadio id="optionChoice" value="#{bean.choice}"
<f:selectItem itemLabel="B" itemValue="choiceB" />
<f:selectItem itemLabel="A" itemValue="choiceA" />
</p:selectOneRadio>
<p:commandButton value="Save"
actionListener="#{bean.save}"
update="dialogId"
oncomplete="ajaxComplete(xhr, status, args)">
</h:form>
...
<p:dialog widgetVar="dialog" id="dialogId">
<p:tabView id="tabViewX">
<p:tab id="tabA" title="Tab A">
<h:panelGrid id="gridA" rendered="#{bean.choice eq 'choiceA'}">
<p:inputTextarea value="#{bean.textA}" />
<h:button />
</h:panelGrid>
<h:panelGrid id="gridB" rendered="#{bean.choice eq 'choiceB'}">
<p:inputTextarea value="#{bean.textB}" />
</h:panelGrid>
</p:tab>
</p:tabView>
</p:dialog>
Any suggestions why the update
attribute of the p:commandButton
updates only the inputTextArea's value
but not the panelGrid's rendered
?
I've also tried update="tabViewX:gridA tabViewX:gridB"
. Not working either.
JSF version: Mojarra JSF API (javax.faces/2.1) 2.1.5 (20111123- SNAPSHOT). Primefaces 3.0.0 – Murat 2 mins ago edit
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论