2012-08-30 42 views
3

我要延長下列元素的複合組件屬性最簡單的方法是使用JSF組件?所以,我創建了以下內容:繼承組分,其中延伸的現有JSF組件

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:composite="http://java.sun.com/jsf/composite"> 
    <head> 
     <title>Not present in rendered output</title> 
    </head> 
    <body> 
     <composite:interface> 
      <composite:attribute name="depressImage" required="false" /> 
     </composite:interface> 

     <composite:implementation> 
      <h:commandButton onmousedown="[some JS here to change the img src to the value of #{cc.attrs.depressImage}]" /> 
     </composite:implementation> 
    </body> 
</html> 

我的問題是,不必鍵入所有可能attruibutes和映射EL是有辦法來自動填充它們(例如命令按鈕的動作和價值等。 )?

回答

3

不幸的是,沒有辦法以這種方式自動繼承它們。你真的必須重新定義它們。對於真正的自定義組件,您還必須按照相同的方式對.taglib.xml文件執行相同操作,因此這不僅是複合組件中的問題,而且也是真正的自定義組件中的問題。標籤屬性不支持任何形式的繼承。

請考慮只重新定義您現在絕對需要的那些,並且只根據需要添加新的。