【问题标题】:reRender a panelGroup or region depending on what is selected on selectOneRadio根据在 selectOneRadio 上选择的内容重新渲染面板组或区域
【发布时间】:2011-09-04 23:22:53
【问题描述】:

基本上就是这个问题: JSF 2.0 How to display a different h:panelGroup each time an item is selected from a selectOneMenu

但我使用的是 selectOneRadio,但我没有答案说它修复的 f:ajax。 知道我可以做些什么来重新渲染我的 panelGroups 吗?

我尝试过使用 a4j:support 但没有成功。看起来它会重新渲染,但没有任何变化。也许我做错了什么。所以,我在 selectOneRadio 上放了一个 onclick="submit()" 并且它工作但它再次加载了整个页面。

<h:selectOneRadio value="#{myBean.selectedItem}" >
 <a4j:support event="onclick" reRender="regionSomeItem,regionAnotherItem" />
 <div class="cssClass">
  <f:selectItem itemValue="someItem" itemLabel="Some Item"/>
 </div>
 <div class="cssClass">
  <f:selectItem itemValue="anotherItem" itemLabel="Another Item"/>
 </div>
 <div class="clear"></div>
</h:selectOneRadio>

<a4j:region id="regionSomeItem" rendered="#{condition for some item}"/>

<a4j:region id="regionAnotherItem" rendered="#{condition for another item}"/>

【问题讨论】:

    标签: java jsf ajax4jsf


    【解决方案1】:

    您需要在 a4j:region 之外创建一个不呈现标签的组。它似乎与试图重新渲染它的标签 reRender 冲突。

    <h:selectOneRadio value="#{myBean.selectedItem}" >
     <a4j:support event="onclick" reRender="allItemsInOneGroup" />
    </h:selectOneRadio>
    
    <h:panelGroup id="allItemsInOneGroup">
    
    <a4j:region rendered="#{condition for some item}">
    </a4j:region>
    
    <a4j:region rendered="#{condition for another item}">
    </a4j:region>
    
    </h:panelGroup>
    

    【讨论】:

    • 我已经在做。它不起作用,除非我重新渲染一个刷新整个页面的“提交()”:(
    • @pringlesinn - 你能编辑你的问题并添加你正在重新渲染的区域吗?
    • 我编辑了你的答案,因为我找到了答案,不想在其他地方回答。
    猜你喜欢
    • 1970-01-01
    • 2017-09-24
    • 1970-01-01
    • 2020-03-31
    • 2020-02-05
    • 1970-01-01
    • 1970-01-01
    • 2021-06-03
    • 1970-01-01
    相关资源
    最近更新 更多