JSF ReRender 支持 selectBooleanCheckbox
我有一个 JSF 页面,我希望在该页面上有一个复选框,单击该复选框将从页面中添加/删除某些其他表单字段。这是我当前用于该复选框的(简化的)代码:
<h:selectBooleanCheckbox title="showComponentToReRender" value="#{backingBean.showComponentToReRender}">
<a4j:support event="onsubmit" reRender="componentToReRender" />
</h:selectBooleanCheckbox>
这是我想要隐藏的组件的代码:
<h:selectOneMenu id="componentToReRender" value="#{backingBean.value}" rendered="#{valuesList.rowCount>1 && backingBean.showComponentToReRender}">
<s:selectItems value="#{valuesList}" var="value"/>
</h:selectOneMenu>
目前,单击该复选框不会执行任何操作; “selectOneMenu”不会消失。我做错了什么?
I have a JSF page on which I want to have a checkbox that, when clicked, will add/remove certain other form fields from the page. Here is the (simplified) code I currently have for the checkbox:
<h:selectBooleanCheckbox title="showComponentToReRender" value="#{backingBean.showComponentToReRender}">
<a4j:support event="onsubmit" reRender="componentToReRender" />
</h:selectBooleanCheckbox>
Here is the code for the component I want to hide:
<h:selectOneMenu id="componentToReRender" value="#{backingBean.value}" rendered="#{valuesList.rowCount>1 && backingBean.showComponentToReRender}">
<s:selectItems value="#{valuesList}" var="value"/>
</h:selectOneMenu>
Currently, clicking the checkbox does nothing; that "selectOneMenu" will not go away. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将
componentToReRender
包装在:或
,实际上,您将拥有:
如果您使用
panelGroup
,则更改reRender="componentToReRenderWrapper"
,或者删除该属性,如果您使用 <代码>输出面板。在 RichFaces 中找到了确切的解释文档:
You need to wrap the
componentToReRender
in either:<h:panelGroup id="componentToReRenderWrapper">
or
<a4j:outputPanel id="componentToReRenderWrapper">
So, effectively you will have:
and change the
reRender="componentToReRenderWrapper"
in case you usepanelGroup
, or remove that attribute, in case you useoutputPanel
.Found the exact explanation in the RichFaces docs:
不要忘记在 a4j:outputPanel 上设置 ajaxRendered="true"
Don't forget to set ajaxRendered="true" on the a4j:outputPanel