2
我的工作:的豐富重新呈現部分:popupPanel
- 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標籤中,那麼這個代碼將不起作用。 這是代碼片段:
<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的一部分。所以,我有兩個問題:
- 爲什麼呢?
- 我怎樣才能使它發揮作用?
謝謝弗拉基米爾!你是對的,domElementAttachment可以做到這一點。 – Hubert