2012-04-24 106 views
2

我試圖創建一個自定義標籤,將作爲一個包裝標準組件,並定義了一些常用的屬性值JSF自定義標籤的包裝的動態參數

例如自定義標籤看起來像這樣

<ui:component xmlns="http://www.w3.org/1999/xhtml" 
xmlns:h="http://java.sun.com/jsf/html" 
xmlns:a4j="http://richfaces.org/a4j" 
xmlns:f="http://java.sun.com/jsf/core" 
xmlns:ui="http://java.sun.com/jsf/facelets" 
xmlns:c="http://java.sun.com/jstl/core"> 

    <rich:datascroller fastControls="false" fastStep="false" maxPages="20" id="#{value}"/> 

</ui:component> 

然後我就能每次我需要一個像

<my:dataTable id="componentId"/> 

我的問題datascroller組件時使用這個標籤是我是否能提供我的自定義標籤與ATTRIB它將被「轉移」到jsf組件,而不用明確指定每個組件。例如,考慮以下使用我的自定義組件

<my:dataTable id="componentId" pagesVar="books" stepControls="true"/> 

的這一個

<my:dataTable id="componentId" pagesVar="items" renderIfSinglePage="false"/> 

屬性pagesVar,stepControls,renderIfSinglePage應該傳遞給富人:datascroller組件。我知道我可以做這樣的事情

<rich:datascroller pagesVar=#{pagesVar ? pagesVar : ''} stepControls=#{stepControls ? true: false}/> 

,但我不知道是否有通過所有屬性,而無需指定他們

回答

1

中的每一個方式,但我想知道如果有一種方法以通過所有屬性而不指定它們中的每一個

不,標籤屬性不支持任何形式的繼承。

但是,您可以更多地簡化您的特定示例。

<rich:datascroller pagesVar="#{pagesVar}" stepControls="#{stepControls}" />