0

拡張データテーブルで行が選択されているかどうかに基づいて、画像を前後に入れ替えようとしています。非アクティブ状態で画像を表示することはできますが、切り替える方法がわかりません。テーブル定義コードは次のとおりです。

<rich:extendedDataTable style="width: 800px; height: 150px;" 
rowClasses="Row0,Row1" value="#{myBean.exceptions}" var="exception"
selectionMode="single" id="Table" selection="#{myBean.exceptionSelection}">
<a4j:ajax event="selectionchange" listener="#{myBean.rowListener}" render=""/>

これが、画像を切り替えたい列です。アイデアは、同じディレクトリにあるfilledRadioButtonという画像に変更することです:

<rich:column id="selected_col" label="Selection">
<f:facet name="header">
<a4j:commandLink value="Selection" render="table"/>
</f:facet>
<h:graphicImage value="../resources/img/emptyRadioButton.jpg"/>
</rich:column>

ありがとう

4

1 に答える 1

0

dataTable のajaxKeys属性を使用して、ajax 更新用の行 (複数可) を具体的に参照できます。したがって、これを有効にするには:

  1. ajaxKeysデータ テーブルの属性をSet<Integer>バッキング Beanの にバインドします。このセットにはid、データテーブル内の特定のエンティティを参照する一意の型の値が保持され、ajax 応答で更新されます。

  2. ajax 経由で更新したいのid属性をのリストに追加します。画像の値を動的な式に設定して、バッキング Bean で切り替えることができるようにします。<h:graphicImage/>render<a4j:ajax/>

     <a4j:ajax event="selectionchange" listener="#{myBean.rowListener}" render="indicatorImg"/>        
     <h:graphicImage id="indicatorImg" value="#{myBean.desiredImagePath}"/>
    
  3. ajax リスナーを配線して、選択したエンティティの ID をajaxKeysSet に追加し、必要に応じてdesiredImagePathプロパティを変更します。

    public void rowListener(AjaxBehaviourEvent evt){
    //I assume you're already managing your selection properly
    //Change the value of the desiredImagePath here too.
     ajaxKeysSet.add(mySelection.getId()); //if you want to update multiple rows
            OR
     ajaxKeysSet = Collections.singleton(mySelection.getId()); //save a single id for ajax update
    }
    
于 2012-11-10T05:09:39.327 に答える