2013-02-04 90 views
2

爲了獲得數據表的行號,我在這裏得到了一個答案,我可以將dataTable直接綁定到視圖(JSF 2 dataTable row index without dataModel)。將多個JSF數據表綁定到查看

我在複合組件中使用該函數,並且可能在同一頁中有幾個。我相信綁定使得不可能在每個頁面上使用多個組件;是否有可能以某種方式「分開」綁定每個表?

+0

那麼你會綁定每個表上不同的託管bean,或不同的屬性的支持bean?爲什麼會是這個問題? – partlov

回答

1

使用UIData屬性創建支持組件類。

@FacesComponent("fooComponent") 
public class FooComponent extends UINamingContainer { 

    private UIData table; 

    // +getter +setter 
} 

並將其綁定到#{cc.table}代替(該#{cc}指當前背襯組件實例)。

<cc:interface componentType="fooComponent"> 
    ... 
</cc:interface> 
<cc:implementation> 
    <h:dataTable binding="#{cc.table}" ...> 
     <h:column>#{cc.table.rowIndex + 1}</h:column> 
     ... 
    </h:dataTable> 
</cc:implementation> 
+0

作品。謝謝! – nivis

+0

不客氣。 – BalusC

+0

只是注意到我無法在p:commandLink中使用cc.table.RowIndex: nivis

0

只需使用ui:重複,而不是通過varStatus.index內置支持。

+0

我懷疑OP是否知道這個功能存在於ui中:repeat。 – Neuralrank