问题
As the subject said, the needed doctype is not rendered in my JSF pages. My used versions:
- Payara Server Payara Server 4.1.2.181 #badassfish (build 220)]]
- Mojarra 2.3.3 ( 20171008-2230 673408fa9199477d87f44521ff873d709128c88b)
- PrimeFaces 6.2 ("official" version)
I already tried the bundled (2.2.14/13/15?) version, no change, so I upgraded to 2.3.3 from github (official release).
In my entire project I have only one doctype and that is in my "master" template:
base.tpl
:
<?xml version="1.0" encoding="UTF-8" ?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:pm="http://primefaces.org/mobile">
<h:doctype rootElement="html" public="-//W3C//DTD XHTML 1.0 Transitional//EN" system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<html lang="#{localizationController.locale.language}" xml:lang="#{localizationController.locale.language}" xmlns="http://www.w3.org/1999/xhtml">
<f:view locale="#{localizationController.locale}" contentType="text/html" />
<h:head>
<f:facet name="first">
<ui:insert name="metadata" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
<meta name="apple-mobile-web-app-capable" content="yes" />
</f:facet>
<f:loadBundle var="msg" basename="org.mxchange.localization.generic" />
<f:loadBundle var="project" basename="org.mxchange.localization.project" />
<f:loadBundle var="local" basename="org.mxchange.localization.local" />
<h:outputStylesheet name="/css/custom.css" />
<title>
<h:outputText value="#{initParam['project_title']} - " />
<ui:insert name="document_title">
<h:outputText value="Default document title" />
</ui:insert>
</title>
</h:head>
<h:body>
<pm:page id="master">
<h:panelGroup styleClass="ui-fluid" layout="block">
<pm:header>
<h:panelGroup layout="block">
<h:panelGroup styleClass="page-header" layout="block">
<h1>
<h:outputText value="#{initParam['project_title']} - " />
<ui:insert name="content_header">
<h:outputText value="Default header title" />
</ui:insert>
</h1>
</h:panelGroup>
<h:panelGroup styleClass="page-content-gap" layout="block">
</h:panelGroup>
</h:panelGroup>
</pm:header>
<h:panelGroup styleClass="ui-g" layout="block">
<h:panelGroup styleClass="ui-g-12 ui-md-2" layout="block">
<ui:insert name="menu">
<h:outputText value="Default menu" />
</ui:insert>
<ui:include src="/WEB-INF/templates/widgets/locale_change_widget.tpl" />
</h:panelGroup>
<h:panelGroup styleClass="ui-g-12 ui-md-10 ui-g-nopad" layout="block">
<h:panelGroup styleClass="ui-g-12 ui-g-nopad">
<ui:insert name="content">
<h:outputText value="Default content" />
</ui:insert>
</h:panelGroup>
</h:panelGroup>
<h:panelGroup styleClass="ui-g-12 page-footer" layout="block">
<ui:insert name="footer">
<h:outputText value="Default footer" />
</ui:insert>
</h:panelGroup>
</h:panelGroup>
<h:panelGroup styleClass="error-container" layout="block">
<p:growl showDetail="true" sticky="true">
<p:autoUpdate />
</p:growl>
<p:ajaxExceptionHandler
type="javax.faces.application.ViewExpiredException"
update="exceptionDialog"
onexception="PF('exceptionDialog').show();"
/>
<p:dialog id="exceptionDialog" closable="true" closeOnEscape="true" header="Exception '#{pfExceptionHandler.type}' occured!" widgetVar="exceptionDialog"
height="500px">
<div class="para">
<h:outputText value="#{msg.EXCEPTION_MESSAGE}:" />
<h:outputText value="#{pfExceptionHandler.message}" />
</div>
<div class="para">
<h:outputText value="#{msg.EXCEPTION_STACK_TRACE}:" />
<h:outputText value="#{pfExceptionHandler.formattedStackTrace}" escape="false" />
</div>
<div class="para">
<p:button onclick="window.location.href = document.location.href;"
value="#{msg.RELOAD_PAGE}"
rendered="#{pfExceptionHandler.type == 'javax.faces.application.ViewExpiredException'}" />
</div>
</p:dialog>
</h:panelGroup>
</h:panelGroup>
</pm:page>
</h:body>
</html>
</ui:composition>
Many JSF pages looks like this:
some_guest_page.xhtml
:
<?xml version="1.0" encoding="UTF-8" ?>
<ui:composition template="/WEB-INF/templates/guest/guest_base.tpl"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:define name="guest_title">
<h:outputText value="#{msg.PAGE_TITLE_INDEX_FOO}" />
</ui:define>
<ui:define name="content_header">
<h:outputText value="#{msg.CONTENT_TITLE_INDEX_FOO}" />
</ui:define>
<ui:define name="content">
<!-- @TODO Here goes your content. //-->
</ui:define>
</ui:composition>
The mentioned guest_base.tpl
is a layer beetween the actual page and my "master" template:
guest_base.tpl
:
<?xml version="1.0" encoding="UTF-8" ?>
<ui:composition
template="/WEB-INF/templates/base.tpl"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<ui:define name="document_title">
<ui:insert name="document_guest_title">
<h:outputText value="Default guest title" />
</ui:insert>
</ui:define>
<ui:define name="menu">
<ui:fragment rendered="#{featureController.isFeatureEnabled('guest_menu')}">
<ui:include src="/WEB-INF/templates/guest/guest_menu.tpl" />
</ui:fragment>
</ui:define>
<ui:define name="footer">
<ui:include src="/WEB-INF/templates/guest/guest_footer.tpl" />
</ui:define>
</ui:composition>
Any ideas on how to fix this is warmly welcome. :-)
UPDATE:
Fixed base.tpl
slightly. Now at least the locale is being correctly loaded again. f:view
seems to also cover at least h:head
, h:body
and f:loadBundle
which makes sense:
f:view
component sets the localef:loadBundle
loads the with the set locale associated message bundle
But now, still the major problem, no doctype
, is still present.
来源:https://stackoverflow.com/questions/45537018/doctype-not-rendered-in-jsf-master-template