【问题标题】:rerender part of rich:popupPanel重新渲染丰富的部分:popupPanel
【发布时间】:2012-11-17 02:19:18
【问题描述】:

我正在合作:

- RichFaces 4.2.2
- Mojarra 2.1.14

让我们看看下面的简单代码:

<h:form>
    <h:selectOneRadio value="#{testBean.option}" >
        <f:selectItem itemValue="0" itemLabel="Option 0"/>
        <f:selectItem itemValue="1" itemLabel="Option 1"/>
        <f:ajax execute="@this" render="infoPanelId"/>
    </h:selectOneRadio>
    <a4j:outputPanel id="infoPanelId">
        <h:outputText value="Option 0 selected" rendered="#{testBean.option == '0'}"/>
        <h:outputText value="Option 1 selected" rendered="#{testBean.option == '1'}"/>
    </a4j:outputPanel>
</h:form>

和 bean 代码:

@ManagedBean(name="testBean")
@ViewScoped
public class TestBean implements Serializable{

    private String option;

    public String getOption() {
        return option;
    }

    public void setOption(String option) {
        this.option = option;
    }
}

它工作得很好,而且很简单。重新渲染按预期工作。 但是如果我们把这个简单的代码放在 rich:popupPanel 标记中,那段代码就不起作用了。 这是代码sn-p:

<h:form>
    <a4j:commandButton 
        value="show popup" 
        oncomplete="#{rich:component('testPopup')}.show()"
        render="testPopup"
    />

    <rich:popupPanel id="testPopup" modal="false" autosized="true" resizable="false">
        <f:facet name="header">
            <h:outputText value="popup"/>
        </f:facet>
        <h:panelGrid columns="1">
            <h:selectOneRadio value="#{testBean.option}" >
                <f:selectItem itemValue="0" itemLabel="Option 0"/>
                <f:selectItem itemValue="1" itemLabel="Option 1"/>
                <f:ajax execute="@this" render="infoPanelId"/>
            </h:selectOneRadio>
        <a4j:outputPanel id="infoPanelId">
                <h:outputText value="Option 0 selected" rendered="#{testBean.option == '0'}"/>
                <h:outputText value="Option 1 selected" rendered="#{testBean.option == '1'}"/>
            </a4j:outputPanel>
        </h:panelGrid>
    </rich:popupPanel>
</h:form>

所以popupPanel里面的代码不起作用。我无法重新渲染 popupPanel 的一部分。所以我有两个问题:

  1. 为什么?
  2. 我怎样才能让它工作?

【问题讨论】:

    标签: jsf jsf-2 richfaces rerender popuppanel


    【解决方案1】:

    1) 因为默认情况下popupPanel 显示在&lt;body&gt; 元素内

    2) 将domElementAttachment="form" 添加到rich:popupPanel 应该会有所帮助

    【讨论】:

    • 谢谢弗拉基米尔!你是对的,domElementAttachment 可以解决问题。
    猜你喜欢
    • 2011-06-11
    • 2012-02-24
    • 2011-06-14
    • 1970-01-01
    • 2013-04-30
    • 1970-01-01
    • 2016-10-08
    • 2011-06-16
    • 1970-01-01
    相关资源
    最近更新 更多