【问题标题】:JSF 2.0 dynamic attributes without creating new componentsJSF 2.0 动态属性,无需创建新组件
【发布时间】:2011-04-19 06:18:55
【问题描述】:

如果不创建自己的属性,如何向未定义这些属性的组件添加新属性。

我想做这样的事情

<h:commandButton actionListener="#{manager.saveNew}" value="#{i18n['School.create']}" secured="true" />

或者至少是一种允许开发人员分配安全属性的方法。

有什么想法吗?

【问题讨论】:

    标签: java jsf jsf-2


    【解决方案1】:

    您可以在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

    【讨论】:

      猜你喜欢
      • 2011-06-25
      • 2021-08-01
      • 1970-01-01
      • 2012-02-01
      • 2013-03-24
      • 1970-01-01
      • 2011-12-08
      相关资源
      最近更新 更多