加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

JSF ReRender支持selectBooleanCheckbox

发布时间:2020-12-16 02:46:01 所属栏目:百科 来源:网络整理
导读:我有一个JSF页面,我希望在其中有一个复选框,单击该复选框时,将从页面添加/删除某些其他表单字段.这是我目前为复选框提供的(简化)代码: h:selectBooleanCheckbox title="showComponentToReRender" value="#{backingBean.showComponentToReRender}" a4j:suppo
我有一个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 &amp;&amp; backingBean.showComponentToReRender}">
   <s:selectItems value="#{valuesList}" var="value"/>
</h:selectOneMenu>

目前,单击复选框不会执行任何操作“selectOneMenu”不会消失.我究竟做错了什么?

解决方法

您需要将componentToReRender包装在以下任一位置:

< h:panelGroup id =“componentToReRenderWrapper”>

要么

< a4j:outputPanel id =“componentToReRenderWrapper”>

所以,实际上你会有:

<h:panelGroup id="componentToReRenderWrapper">
    <h:selectOneMenu id="componentToReRender" value="#{backingBean.value}" rendered="#{valuesList.rowCount>1 &amp;&amp; backingBean.showComponentToReRender}">
       <s:selectItems value="#{valuesList}" var="value"/>
    </h:selectOneMenu>
</h:panelGroup>

如果使用panelGroup,则更改reRender =“componentToReRenderWrapper”,或者删除该属性,以防使用outputPanel.

在RichFaces文档中找到了确切的解释:

Most common problem with using reRender is pointing it to the component that has a “rendered” attribute. Note,that JSF does not mark the place in the browser DOM where the outcome of the component should be placed in case the “rendered” condition returns false. Therefore,after the component becomes rendered during the Ajax request,RichFaces delivers the rendered code to the client,but does not update a page,because the place for update is unknown. You need to point to one of the parent components that has no “rendered” attribute. As an alternative,you can wrap the component with layout=”none” .

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读