我想创建一个复合组件,将一些通用元数据添加到 View 中,例如:
<viewController:metadata controller="orderController"/>
组件:
<composite:interface>
<composite:attribute name="controller" />
</composite:interface>
<composite:implementation>
<f:metadata>
<f:viewParam name="id" value="#{cc.attrs.controller.id}" />
<f:event type="preRenderView"
listener="#{cc.attrs.controller.initConversation}" />
</f:metadata>
</composite:implementation>
我做了类似的事情来为所有 View 添加一个按钮栏并且它工作正常,但它似乎不可能与 f:metadata 一起使用。
我是对的还是我的代码有问题?
谢谢
最佳答案
这是不可能的。 <f:metadata>
必须进入与 View ID 关联的 View 。另见 tag documentation (强调我的):
Declare the metadata facet for this view. This must be a child of the
<f:view>
. This tag must reside within the top level XHTML file for the given viewId, or in a template client, but not in a template. The implementation must insure that the direct child of the facet is aUIPanel
, even if there is only one child of the facet. The implementation must set the id of theUIPanel
to be the value of theUIViewRoot.METADATA_FACET_NAME
symbolic constant.
关于jsf-2 - 为 f :metadata 创建复合组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11971927/