简体   繁体   English

重新渲染rich:popupPanel的一部分

[英]rerender part of rich:popupPanel

I'm working with: 我正在与:

- RichFaces 4.2.2
- Mojarra 2.1.14

Lets look at simple code below: 让我们看下面的简单代码:

<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>

and the bean code: 和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;
    }
}

It works fine, and it is simple. 它工作正常,而且很简单。 Rerendering works as expected. 渲染工作正常。 But if we place this simple code inside rich:popupPanel tag, that code will not work. 但是,如果我们将这个简单的代码放在rich:popupPanel标记中,那么该代码将无法正常工作。 This is the code snippet: 这是代码片段:

<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>

So the code inside popupPanel does not work. 因此popupPanel中的代码不起作用。 I cannot rerender part of popupPanel. 我无法重新渲染popupPanel的一部分。 So I have two questions: 所以我有两个问题:

  1. why? 为什么?
  2. How can I make it work? 我该如何运作?

1) Because by default popupPanel is shown inside the <body> element 1)因为默认情况下popupPanel显示在<body>元素内

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM