我希望扩展以下内容: h:commandButton action="#{menuController.xyz}" value="xyz" image="images/buttons/xyz.png" alt="xyz".....[more attributes]..../ 包含生成按下按钮的代码: h:commandButton action="#{menuController.xyz}
<h:commandButton action="#{menuController.xyz}" value="xyz"
image="images/buttons/xyz.png" alt="xyz".....[more attributes]..../>
包含生成按下按钮的代码:
<h:commandButton action="#{menuController.xyz}" value="xyz"
image="images/buttons/xyz.png" alt="xyz"
onmousedown="[some JS here to change image src]"
.....[more attributes]..../>
我知道最好的方法是使用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有没有办法自动填充它们(例如命令按钮操作和值等)?
不幸的是,没有简洁的方法可以通过这种方式自动继承它们.你真的必须重新定义它们.对于真正的自定义组件,您还必须对.taglib.xml文件执行相同的操作,因此这不仅是复合组件中的问题,也是真实自定义组件中的问题.标记属性不支持任何形式的继承.考虑只重新定义您现在绝对需要的那些,并仅按需添加新的.
