1

「変更」ajaxイベントをサポートするJSF 2に複合コンポーネントを実装しようとしています。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 のバグですか?

4

1 に答える 1

1

これ:

<h:panelGroup id="#{cc.clientId}"

間違っています。 #{cc.clientId}その panelGroup の親であるコンポーネントの ID です。同じ ID を持つように設定するのは正しくありません。" " のような ID を与えると、" myComponentPanel" の絶対 ID (コンポーネント ツリーに配置された場合) を持つことになります#{cc.clientId}:myComponentPanel

これを修正すれば、ajax の動作が機能すると思われます。

于 2011-04-03T02:56:49.850 に答える