【发布时间】:2011-04-19 06:18:55
【问题描述】:
如果不创建自己的属性,如何向未定义这些属性的组件添加新属性。
我想做这样的事情
<h:commandButton actionListener="#{manager.saveNew}" value="#{i18n['School.create']}" secured="true" />
或者至少是一种允许开发人员分配安全属性的方法。
有什么想法吗?
【问题讨论】:
如果不创建自己的属性,如何向未定义这些属性的组件添加新属性。
我想做这样的事情
<h:commandButton actionListener="#{manager.saveNew}" value="#{i18n['School.create']}" secured="true" />
或者至少是一种允许开发人员分配安全属性的方法。
有什么想法吗?
【问题讨论】:
您可以在h:commandButton 中使用f:attribute。
<h:commandButton actionListener="#{manager.saveNew}
value="#{i18n['School.create']}">
<f:attribute name="secured" value="true" />
</h:commandButton>
在你的行动方法中:
public void saveNew(ActionEvent event) {
String secured = (String) event.getComponent().getAttributes().get("secured");
}
这是一个关于这个主题的comprehensive tutorial。
【讨论】: