我希望扩展以下元素:
<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>
我的问题是,无需输入所有可能的属性并映射 EL,有没有办法自动填充它们(例如命令按钮操作和值等)?