Tôi đã trải qua nhiều nguồn khác nhau như:Thành phần siêu dữ liệu cần được lồng trong thẻ f: metadata. Gợi ý: đi kèm trong các thành phần cần thiết trong <f:metadata>
và nó có vẻ là vấn đề đã được cố định trong JSF 2.2 .1, khi tôi cố gắng sử dụng, tôi đang gặp vấn đề, dưới đây là các cấu hình của tôi:
template.xhtml:
<!DOCTYPE html>
<html lang="#{languageBean.language}"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:fn="http://xmlns.jcp.org/jsp/jstl/functions"
xmlns:p="http://primefaces.org/ui" xmlns:o="http://omnifaces.org/ui"
xmlns:of="http://omnifaces.org/functions">
<!-- Enables CTRL+SHIFT+D for activating Facelets debug window -->
<ui:debug />
<f:view locale="#{languageBean.language}" encoding="UTF-8" contentType="text/html">
<!-- Client templates can insert f:metadata here, and this will NOT show up in the showcase page source code -->
<ui:insert name="meta" />
<c:set var="contextPath" value="${pageContext.request.contextPath}"
scope="application" />
<f:loadBundle var="messageResource" basename="MessageResource" />
<h:head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<meta http-equiv="X-UA-Compatible"
content="EmulateIE8,IE=edge,chrome=1" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Connect" />
<meta name="keywords"
content="timeline, 3d, css, css3, css-only, transitions, responsive, fluid" />
<meta name="author" content="FriendsMirror" />
<link rel="shortcut icon"
href="#{request.contextPath}/Friendsmirror.ico" />
<ui:insert name="js"/>
<h:outputStylesheet library="css" name="common.css" />
<h:outputStylesheet library="css" name="main.css" />
<ui:insert name="css"/>
<ui:insert name="onloadScript"/>
<title><ui:insert name="title">#{messageResource['connect.main.title.main.title']}</ui:insert></title>
</h:head>
<h:body>
<ui:insert name="content" />
</h:body>
</f:view>
</html>
Page:
<ui:composition template="/WEB-INF/templates/discussion_layout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
<ui:define name="meta">
<f:metadata>
<f:viewParam name="sessionKey" value="#{discussionWrapperBean.sessionKey}" />
<f:viewParam name="ref" value="#{discussionWrapperBean.ref}" />
<f:viewParam name="pId" value="#{discussionWrapperBean.pId}" />
<f:viewParam name="dId" value="#{discussionWrapperBean.discussionId}" />
<f:viewParam name="dName" value="#{discussionWrapperBean.discussionName}" />
<f:viewAction action="#{discussionWrapperBean.loadInitDiscussion}" onPostback="false" />
</f:metadata>
</ui:define>
<ui:define name="title">
<ui:fragment rendered="#{discussionWrapperBean.profileId != null}">
#{discussionWrapperBean.userBean.firstName} #{discussionWrapperBean.userBean.lastName != null ? discussionWrapperBean.userBean.lastName: ''}#{discussionWrapperBean.pageTitleNotifications != null ? '(' : ''}#{discussionWrapperBean.pageTitleNotifications != null ? discussionWrapperBean.pageTitleNotifications : ''}#{discussionWrapperBean.pageTitleNotifications != null ? ')' : ''}
</ui:fragment>
<ui:fragment rendered="#{discussionWrapperBean.profileId == null}">
#{messageResource['connect.discussion.title']}
</ui:fragment>
</ui:define>
<ui:define name="content">
</ui:define>
</ui:composition>
Maven:
<jsf.version>2.2.1</jsf.version>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${jsf.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${jsf.version}</version>
<scope>provided</scope>
</dependency>
Trong Ui Tôi nhận được vấn đề như: The metadata component needs to be nested within a f:metadata tag. Suggestion: enclose the necessary components within <f:metadata>
thậm chí nó không gọi <f:viewAction>
Mọi đề xuất hoặc trợ giúp sẽ được đánh giá cao.
Một điều tôi nhận thấy trong quá trình triển khai: INFO: Khởi tạo cá móm 2.2.0 (20.130.502-2.118 https://svn.java.net/svn/mojarra~svn/tags/[email protected]) cho bối cảnh /connectWAR
Tôi không chắc chắn lý do tại sao điều này được nói cá móm 2.2.0, mặc dù tôi đã nâng cấp đến 2.2.1
Tại thời điểm tôi đăng câu trả lời, bản sửa lỗi được báo cáo là 2.2.1 nhưng khi tôi kiểm tra lại liên kết vấn đề vẫn đang mở và bây giờ sửa lỗi được báo cáo là 2.2.2. Tôi vẫn gặp vấn đề này với JSF 2.2.1 theo thời gian để bạn không đơn độc. Nếu thông báo làm phiền bạn nhiều thì hãy thay đổi giai đoạn dự án. Đối với 'f: viewAction' tôi đã không thử nó kể từ đó. Tôi sẽ thử lại. – Andy
Cảm ơn bạn Andy ... thông điệp cảnh báo có thể được bỏ qua, nhưng không thể làm việc với, nếu bạn có bất kỳ thay thế thay vì postConstruct sẽ hữu ích. –
Bạn đang sử dụng cái gì? GlasshFish? – Andy