【问题标题】:Can I declare a Composite-Component using only xhtml file and still be able to use the component in a JAVA code我可以只使用 xhtml 文件声明一个复合组件,并且仍然能够在 JAVA 代码中使用该组件吗
【发布时间】:2014-08-16 20:37:23
【问题描述】:

我正在尝试使用 jsf 简单标签创建一个复合组件,而不利用 UIComponent 的优势。我的意思是我不想通过从 UIComponentBase、UIComponentBase 等继承来实现组件。但是,在实现之后,我希望能够在 JAVA 代码中使用该组件。例如,考虑下面的复合组件(我们称之为 MYcompositeComponent):

<html xmlns="http://www.w3.org/1999/xhtml"   
    //...
    xmlns:composite="http://java.sun.com/jsf/composite">
        <composite:interface>
            <composite:attribute name="anything" />
        </composite:interface>
        <composite:implementation>
            #{cc.attrs.anything}
        </composite:implementation>
</html>

然后我想在一个 JAVA 类中使用这个组件,如下所示:

public class JavaClass {
    private MYcompositeComponent mYcompositeComponent;
    // ....
}

【问题讨论】:

    标签: java jsf jsf-2 primefaces composite-component


    【解决方案1】:

    这个问题也有类似的答案。 OmniFaces 有一个名为 Components.includeCompositeComponent(UIComponent parent, String libraryName, String resourceName, String id) 的实用方法,它将以编程方式将您的组件添加到另一个 UIComponent。这将返回复合组件和

    ...如有必要,可以进一步用于在其上设置自定义属性或值表达式。

    【讨论】:

      猜你喜欢
      • 2016-08-27
      • 1970-01-01
      • 2020-02-26
      • 1970-01-01
      • 2016-02-23
      • 2019-04-18
      • 2014-09-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多