2011-12-29 66 views
0

我有一個JSF 2.0複合組件,如下所示:複合組件動作屬性重用?

<composite:interface> 
    <composite:attribute name="id"/> 
    <composite:attribute name="action1" targets="#{cc.clientId}:#{cc.attrs.id}_1" requiered="true"/> 
    <composite:attribute name="action2" targets="#{cc.clientId}:#{cc.attrs.id}_2" requiered="true"/> 
</composite:interface> 

<composite:implementation> 
    <h:commandLink id="#{cc.attrs.id}_1" value="command link 1"/> 
    <h:commandLink id="#{cc.attrs.id}_2" value="command link 2"/> 
</composite:implementation> 

,你可以看到我現在用的命名兩種不同的屬性(動作1,動作2),並將其定位於兩個commandLink的。

我想要做的是:我不想動作1 & action2,我想只有一個名爲「action」的屬性,並將這個動作重用於兩個commandLinks。

謝謝。

回答

1

您可以在targets屬性中指定空格分隔的客戶端ID列表。也the <composite:attribute> tag documentation參見:

如果該元素有一個方法簽名屬性,對象的屬性的值必須被解釋爲的空間(未標籤)相對於頂部(客戶ID 分隔列表<composite:implementation>部分中的組件)。

+0

感謝BalusC做到了。 – 2011-12-29 21:08:59