我正在尝试在 JSF 2 中实现一个复合组件,它将支持“更改”ajax 事件。中央委员会是:
<!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(我无法在 Google App Engine 上制作 2.0.3,这是我的 AS)。我是否错过了应该构建复合组件的方式?还是 Mojarra 2.0.2 中的错误?