我正在尝试使用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;
// ....
}发布于 2014-10-31 03:22:43
对于这个问题,已经有了类似的答案。OmniFaces有一个名为Components.includeCompositeComponent(UIComponent parent, String libraryName, String resourceName, String id)的实用程序方法,它将以编程方式将您的组件添加到另一个UIComponent中。这将返回复合组件,并
...如有必要,可以进一步使用它来设置自定义属性或值表达式。
https://stackoverflow.com/questions/24422948
复制相似问题