2011-08-01 33 views
1

私は「タイトル」属性に値を挿入する必要がありますが、私はそれを行う方法を思ったんだけど、それはのようなものでなければなりません:私は分離するために、コンマで1つの文字列を送信することができます1つのui:repeatで2つの配列を反復処理する方法は?

<ui:repeat //..> 
    <h:graphicImage library="images" name="#{image}" title="#{title}" /> 
</ui:repeat> 

<!-- calling the component --> 
<cs:small_slider images="products/eletricity.jpg,products/water.jpg" > 

<!-- the component with dynamic rendering --> 
<cc:interface> 
    <cc:attribute name="images" type="java.lang.String" required="true" /> 
</cc:interface> 

<cc:implementation> 
    <div id="slider-container"> 
     <div id="slider-small"> 
      <ui:repeat value="#{fn:split(cc.attrs.images, ',')}" var="image"> 
       <h:graphicImage library="images" name="#{image}" /> 
      </ui:repeat> 
     </div> 
    </div> 
</cc:implementation> 

ご存知ですか?

答えて

3

両方の配列の関連項目に同じ配列インデックスがある場合は、のvarStatusで利用可能な配列の1つの現在のループインデックスでアクセスできます。

使用法:

<cs:small_slider 
    images="products/eletricity.jpg,products/water.jpg" 
    titles="Electicity,Water" 
/> 

コンポジットコンポーネント:

<cc:interface> 
    <cc:attribute name="images" type="java.lang.String" required="true" /> 
    <cc:attribute name="titles" type="java.lang.String" required="true" /> 
</cc:interface> 

<cc:implementation> 
    <ui:param name="images" value="#{fn:split(cc.attrs.images, ',')}" /> 
    <ui:param name="titles" value="#{fn:split(cc.attrs.titles, ',')}" /> 

    <div id="slider-container"> 
     <div id="slider-small"> 
      <ui:repeat value="#{images}" var="image" varStatus="loop"> 
       <h:graphicImage library="images" name="#{image}" title="#{titles[loop.index]}" /> 
      </ui:repeat> 
     </div> 
    </div> 
</cc:implementation> 
+0

UIができません:ViewScope豆を破る繰り返し? – Dejell

+0

@BalusC、ありがとう!それは魅力のように動作します=) –

関連する問題