[英]JSF 2 Composite Component doesn't update value with f:ajax
我正在嘗試在JSF 2中實現一個復合組件,該組件將支持“更改” ajax事件。 CC為:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:composite="http://java.sun.com/jsf/composite">
<!-- INTERFACE -->
<composite:interface name="inputText">
<composite:attribute name="label" />
<composite:attribute name="value" />
<composite:attribute name="disabled" default="false" />
<composite:attribute name="required" default="false" />
<composite:attribute name="rendered" default="true" />
<composite:clientBehavior name="change" event="change"
targets="#{cc.clientId}:input" />
</composite:interface>
<!-- IMPLEMENTATION -->
<composite:implementation>
<h:panelGroup id="#{cc.clientId}" rendered="#{cc.attrs.rendered}">
<h:outputLabel value="#{cc.attrs.label}" for="input" />
<h:inputText id="input" label="#{cc.attrs.label}"
value="#{cc.attrs.value}" disabled="#{cc.attrs.disabled}"
required="#{cc.attrs.required}" />
<h:message for="input" />
</h:panelGroup>
</composite:implementation>
</html>
現在,我嘗試以以下形式使用它:
<h:form id="form">
<input:inputText value="#{bean.value}" label="d1" id="d1">
<f:ajax event="change" update="@this,d2,d3" />
</input:inputText>
<h:inputText value="#{bean.value}" id="d2">
<f:ajax event="change" update="@this,d1,d3" />
</h:inputText>
<h:outputText id="d3" value="#{bean.value}" />
</h:form>
據我了解,如果我更改d1 ,則d2和d3應該顯示d1的值,如果我更改d2 ,則d1和d3都應相應地更改。
問題是,當我更改d2中的值時,它僅反映在d3中,而d1保持空白,而當我更改d2時 ,d1和d2保持空白。
我正在使用Mojarra 2.0.2(我無法在自己的AS的Google App Engine上制作2.0.3)。 我是否錯過了構建復合組件的方式? 還是Mojarra 2.0.2中的錯誤?
這個:
<h:panelGroup id="#{cc.clientId}"
是不正確的。 #{cc.clientId}
是組件的ID,它是該panelGroup的父級。 將它們設置為具有相同的ID是不正確的。 給它一個像“ myComponentPanel
”這樣的ID,它將具有“ #{cc.clientId}:myComponentPanel
”的絕對ID(放在組件樹中時)。
我懷疑如果您糾正此問題,您的ajax行為將起作用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.