如何将UIViewRoot保留为空?这不是组件树的根组件吗?我现在有一个相对简单的JSF webapp,并且不知道它为什么会失败。
特别是,我有一个h:panelGroup
:
<h:panelGroup id="xmlValidationResults" layout="block"
styleClass="tp-form-action-results"
rendered="#{configuration.xmlValidationResult != null}">
工作正常,但如果我添加其他渲染条件:
<h:panelGroup id="xmlValidationResults" layout="block"
styleClass="tp-form-action-results"
rendered="#{configuration.xmlValidationResult != null && configuration.xmlValidationResult.warningOrWorse}">
我最终在我的日志中收到这些错误消息:
20:43:07,796 ERROR LiferayLocalePhaseListener:61 - viewRoot is null!
20:43:07,797 ERROR [render_portlet_jsp:154] java.lang.NullPointerException
at org.portletfaces.bridge.BridgeImpl.indicateNamespacingToConsumers(BridgeImpl.java:594)
at org.portletfaces.bridge.BridgeImpl.doFacesRequest(BridgeImpl.java:426)
at org.portletfaces.bridge.GenericFacesPortlet.doEdit(GenericFacesPortlet.java:138)
at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:330)
at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:93)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:639)
at com.liferay.portlet.InvokerPortletImpl.invokeRender(InvokerPortletImpl.java:726)
为了完整性,这是我的template.xhtml:
<html 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://java.sun.com/jsf/facelets">
<h:head />
<h:body>
<h:outputStylesheet library="css" name="liferay-tableau-portlet.css"
target="head" />
<h:outputScript library="js" name="liferay-tableau-portlet.js" target="head" />
<h:panelGroup styleClass="tp-container" layout="block">
<h:panelGroup styleClass="tp-header" layout="block">
<ui:insert name="header"></ui:insert>
</h:panelGroup>
<h:panelGroup styleClass="tp-content" layout="block">
<ui:insert name="content">Whoops, you should not be seeing this...</ui:insert>
</h:panelGroup>
<h:panelGroup styleClass="tp-footer" layout="block">
<ui:insert name="footer"></ui:insert>
<h:messages id="liferayTableauPortletMessages" globalOnly="true"
showDetails="true" />
</h:panelGroup>
</h:panelGroup>
</h:body>
</html>
这是我的页面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core">
<body>
<ui:composition template="template.xhtml" xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html">
<ui:define name="header">
<h:panelGroup styleClass="tp-application-info">
<span>#{configuration.applicationName}
#{configuration.applicationVersion}
(#{configuration.applicationBuildTimestamp})</span>
</h:panelGroup>
</ui:define>
<ui:define name="content">
<h:form id="form">
<h:panelGroup id="formFields" styleClass="tp-form-fields">
<fieldset class="tp-form-fieldset">
<div>
<h:outputLabel id="xmlLabel" for="xml" styleClass="tp-label">XML Configuration:</h:outputLabel>
</div>
<h:inputTextarea id="xml" value="#{configuration.xml}"
validator="#{configuration.validateXml}" cols="80" rows=10 />
</fieldset>
</h:panelGroup>
<h:panelGroup id="xmlValidationResults" layout="block"
styleClass="tp-form-action-results"
rendered="#{configuration.xmlValidationResult != null}">
<span>can you see me?</span>
</h:panelGroup>
<h:panelGroup id="formActions" styleClass="tp-form-actions">
<h:commandLink id="createWebContentAction" styleClass="tp-action"
action="#{configuration.createWebContent}">
<span>Create Web Content</span>
</h:commandLink>
<h:commandLink id="extractTableauThumbnailsAction"
styleClass="tp-action"
action="#{configuration.extractTableauThumbnails}">
<span>Extract Tableau Thumbnails</span>
</h:commandLink>
</h:panelGroup>
</h:form>
</ui:define>
</ui:composition>
</body>
</html>
答案 0 :(得分:2)
您忘记了<f:view/>
和<h:head/>
周围的<h:body>
标记。