jsf - 如何使用 f :metadata JSF tag?

标签 jsf metadata

我有一个 View 包含在另一个 View 中。我在包含的 View 中遇到 f:metadata 问题。不知道该怎么做。我已经更新了两个 View 并重新启动了服务器。没有运气。

家长 View

<ui:include src="sub_entityIndexPagination.xhtml">
    <ui:param name="entityIndexBean" value="#{articleIndexBean}"/>
</ui:include>

subview

<ui:composition 
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:c="http://java.sun.com/jsp/jstl/core"      
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  >

<f:metadata>
    <f:viewParam name="pn" value="#{entityIndexBean.currentEntityPageNumber}" />
     <f:event type="preRenderView" listener="#{entityIndexBean.toCurrentEntityPage()}" />
</f:metadata>

<c:forEach var="pageNumber" begin="1" end="${entityIndexBean.getEntityPageCount()}">   
    <h:outputLink value="ar_index.xhtml">
        <h:outputText value="${pageNumber}" />
            <f:param name="pn" value="${pageNumber}" />
    </h:outputLink> 
</c:forEach>

JSF 实现

c:\tomee16\lib\myfaces-api-2.1.13.jar

错误

/sub_entityIndexPagination.xhtml at line 9 and column 14 <f:metadata> Parent UIComponent j_id_9 should be instance of UIViewRoot

phaseId=RENDER_RESPONSE(6)

Caused by:
javax.faces.view.facelets.TagException - /sub_entityIndexPagination.xhtml at line 9 and column 14 <f:metadata> Parent UIComponent j_id_9 should be instance of UIViewRoot
at org.apache.myfaces.view.facelets.tag.jsf.core.ViewMetadataHandler.apply(ViewMetadataHandler.java:60)

最佳答案

<f:metadata>不能在包含文件中声明。它必须在顶 View (您指定为“父 View ”的文件)中声明。它应该正是请求 URL 直接引用的 View 。

也就是说,拥有 <html> 是完全错误的在包含文件中。你这样有效地嵌套<html>标签仅导致 syntactically invalid HTML 。花点时间停下来学习 JSF 可能是值得的 some basic HTML first 。 JSF 最终只是一个 HTML 代码生成器。

关于jsf - 如何使用 f :metadata JSF tag?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21803332/

相关文章:

javax.el.PropertyNotFoundException : Property 'printIDs' not found on type but this property is commented 异常

多次调用 JSF Backing Bean 构造函数

asp.net-mvc - 单个 Asp.Net MVC 应用程序中的多个 .edmx

mysql - "Proper"存放MySQL数据库描述的地方

go - GRPC : How to pass value from interceptor to service function

jsf - 如何使用omnifaces合并将空值转换为数字,以便在ChoiceFormat中使用

java - JSF + RichFaces 在我的页面中提供 HTTP 状态 404

jsf - @WebFilter 和 FacesContext.getCurrentInstance() -> 空指针

linux - 在 Whatsapp 中查看图像元数据

python - 在 Python 中更改文件元数据