2

tomahawk selectOneRadio を使用してラジオ ボタンを広げようとしています。私のIDはこんな感じ

<rich:dataTable id="carTable" value="#{cars}" var="car">
    <rich:column>
        <s:decorate id="types" template="/layout/display-text.xhtml">
            <t:selectOneRadio id="models" value="#{car.model}" layout="spread">
                <f:selectItems value="#{models}" />
            </t:selectOneRadio>
            <h:panelGrid columns="2">
                <a:repeat value="#{models}" rowKeyVar="index">
                    <t:radio for="car:carTable:0:types:models" index="#{index}"></t:radio>
                </a:repeat>
            </h:panelGrid>  -->
        </s:decorate>
    </rich:column> 
</rich:dataTable>

要素を調べた後、id を参照しました。しかし、これは機能していません。反復ごとにラジオボタンのIDが異なるためです。t:radio で ID を参照する方法

4

1 に答える 1

1

t:radioのドキュメントには次のように書かれています。

参照される拡張 selectOneRadio コンポーネントの ID。この値は、標準のUIComponent.findComponent()検索アルゴリズムを使用して特定のコンポーネントに解決されます。

a:repeatと思うNamingContainerので、使用して"models"もうまくいきません。コンポーネントのクライアント識別子を使用できます。t:selectOneRadio

このようなもの:

<t:selectOneRadio id="models" value="#{car.model}" layout="spread"
   binding="#{requestScope.modelComponent}">
  <f:selectItems value="#{models}" />
</t:selectOneRadio>
<h:panelGrid columns="2">
  <a:repeat value="#{models}" rowKeyVar="index">
    <t:radio for="#{requestScope.modelComponent.clientId}" index="#{index}" />
  </a:repeat>
</h:panelGrid>

警告:

  1. これにより、キー「modelComponent」を使用して、コンポーネントがリクエスト スコープ マップにバインドされます。これが他のものと衝突しないようにする必要があります
  2. 解決modelComponent.clientIdには JSF 2.0 (JEE6) 以上が必要です

詳細については、こちらを参照してください。古いバージョンでの作業; 等

于 2011-01-23T13:20:44.363 に答える