我经历了不同的来源,如:
似乎问题已在jsf 2.2.1中得到修复,其中当我尝试使用时,我面临问题,下面是我的配置:
所引用:
<!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>
页:
<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>
在Ui,我遇到的问题如下:The metadata component needs to be nested within a f:metadata tag. Suggestion: enclose the necessary components within <f:metadata>
甚至没有调用<f:viewAction>
任何建议或帮助将不胜感激。
我在部署期间注意到的一件事:
信息:为上下文/connectWAR
初始化Mojarra 2.2.0(20130502-2118 https://svn.java.net/svn/mojarra~svn/tags/2.2.0@11930)
我不知道为什么这会告诉Mojarra 2.2.0,即使我已升级到2.2.1
答案 0 :(得分:6)
关于假UI警告,这是由Mojarra issue 2868引起的,并且自2.2.1以来已经修复。
至于<f:viewAction>
仍然没有在2.2.1上工作,自从Java EE 7引入xmlns.jcp.org
XML命名空间域以来的另一个Mojarra错误导致了这个问题。在具体的Mojarra版本2.2.0和2.2.1中,新的XML命名空间域未正确注册JSF 2.0 / 2.1中不存在的所有新JSF 2.2特定标记,例如<f:viewAction>
。实际上,xmlns.jcp.org
将为您提供Mojarra 2.2.0 / 2.2.1 仅 JSF 2.1兼容标签。这完全解释了为什么新的JSF 2.2 <f:viewAction>
不适合你。
您有两个选择:
请改用“旧”java.sun.com
XML命名空间域。新的JSF 2.2特定标签在那里正确注册。
升级到至少Mojarra 2.2.2。自那个版本以来,这个奇怪的错误已得到修复。 Mojarra currently已经在2.2.4。