jsf-2 - 为 f :metadata 创建复合组件

标签 jsf-2 metadata facelets composite-component

我想创建一个复合组件,将一些通用元数据添加到 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 a UIPanel, even if there is only one child of the facet. The implementation must set the id of the UIPanel to be the value of the UIViewRoot.METADATA_FACET_NAME symbolic constant.

关于jsf-2 - 为 f :metadata 创建复合组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11971927/

相关文章:

java - 在 JSF 中,拥有 ui :repeater inside a h:dataTable 是否有效

c# - WCF 元数据缺少操作

spring - 来自 Spring JDBCTemplate 查询方法的结果集元数据

jsf - 有人可以解释一下脸吗?

jsf-2 - 如何防止多个复合组件在 JSF 页面上自行重置?

java - 使用maven使jar成为jsf中的自定义组件

iOS图像元数据如何获取小数值作为分数字符串?

eclipse - eclipse中动态web项目打不开欢迎页

Jsf 如何创建命名容器

jsf-2 - 在 JSF 错误处理程序中使用 ExternalContext.dispatch 会导致页面呈现损坏