UI 布局初始化错误-中心窗格元素不存在,中心窗格是必需元素
UI Layout Initialization Error-The center-pane element does not exist, the center pane is required element
这个关于 JSF(Primefaces) 应用程序的错误 Spring Boot.
在 uploadimages.xhtml 之后出现此错误,我尝试了很多之前提到的关于堆栈溢出的解决方案,包括 web.xml 基于配置的解决方案,但没有为我工作。
1)UI布局初始化错误-中心面板元素不存在
UI Layout Initialization Error-The center-pane element does not exist
2)Error message
Uploadimages.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition 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"
xmlns:p="http://primefaces.org/ui"
template="maintmplt.xhtml">
<head>
</head>
<ui:define name="content">
<div style="text-align: center;">
<h:form id="search" enctype="multipart/form-data">
<div style="width: 80%; margin-left: 20px; margin-right: auto;">
<p:panel id="searchFields2" header="Banner Images Upload"
style="font-weight:bold; font-size:11px;text-align:left;background-color:#F3F1F6">
<p:fieldset legend="Sinhala" toggleable="true" collapsed="true" toggleSpeed="500" style="margin-top: 20px;">
<p:ajax event="toggle" listener="#{BannerUpload.file}" update="search" />
<h:panelGrid columns="2" cellpadding="5">
<p:growl id="messages1" showDetail="true" />
<h:form enctype="multipart/form-data">
<p:growl id="messages" showDetail="true"/>
<p:fileUpload value="#{BannerUpload.file}" mode="simple" skinSimple="true"/>
<br/>
<ui:fragment rendered="#{not empty BannerUpload.file}">
<img src="data:image/png;base64,#{BannerUpload.imageContentsAsBase64}" />
</ui:fragment>
<br/>
<p:commandButton action="#{BannerUpload.preview}" ajax="false" value="Preview" />
<br/>
<p:commandButton value="Submit" ajax="false" action="#{BannerUpload.upload}" disabled="false"/>
</h:form>
</h:panelGrid>
</p:fieldset>
<p:fieldset legend="English" toggleable="true" collapsed="true" toggleSpeed="500" style="margin-top: 20px;">
<h:panelGrid columns="2" cellpadding="5">
<p:growl id="messages2" showDetail="true" />
<h:form enctype="multipart/form-data">
<p:growl id="engMessages" showDetail="true"/>
<p:fileUpload value="#{BannerUpload.file}" mode="simple" skinSimple="true"/>
<br/>
<ui:fragment rendered="#{not empty BannerUpload.file}">
<img src="data:image/png;base64,#{BannerUpload.imageContentsAsBase64}" />
</ui:fragment>
<br/>
<p:commandButton action="#{BannerUpload.preview}" ajax="false" value="Preview" />
<br/>
<p:commandButton value="Submit" ajax="false" action="#{BannerUpload.upload}" disabled="false"/>
</h:form>
</h:panelGrid>
</p:fieldset>
<p:fieldset legend="Tamil" toggleable="true" collapsed="true" toggleSpeed="500" style="margin-top: 20px;">
<h:panelGrid columns="2" cellpadding="5">
<p:growl id="messages3" showDetail="true" />
<h:form enctype="multipart/form-data">
<p:growl id="tamMessages" showDetail="true"/>
<p:fileUpload value="#{BannerUpload.file}" mode="simple" skinSimple="true"/>
<br/>
<ui:fragment rendered="#{not empty BannerUpload.file}">
<img src="data:image/png;base64,#{BannerUpload.imageContentsAsBase64}" />
</ui:fragment>
<br/>
<p:commandButton action="#{BannerUpload.preview}" ajax="false" value="Preview" />
<br/>
<p:commandButton value="Submit" ajax="false" action="#{BannerUpload.upload}" disabled="false"/>
</h:form>
</h:panelGrid>
</p:fieldset>
</p:panel>
</div>
</h:form>
</div>
</ui:define>
</ui:composition>
由于使用了不受支持的命令按钮,我的示例中出现了上述错误。
<p:commandButton action="#{BannerUpload.preview}" ajax="false" value="Preview" />
将其替换为以下代码并使用 Advanced primefaces fileuploader 而不是简单模式,并根据新实现更改您的 java 控制器。
<p:fileUpload fileUploadListener="#{BannerUpload.uploadEnglishImg}" mode="advanced"
dragDropSupport="false" update="messages2" sizeLimit="100000" fileLimit="1"
allowTypes="/(\.|\/)(png)$/" />
更改了代码示例......
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition 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" xmlns:p="http://primefaces.org/ui" template="maintmplt.xhtml">
<ui:define name="content">
<div style="text-align: center;">
<h:form id="search" enctype="multipart/form-data">
<p:growl id="messages" showDetail="true" />
<div style="width: 80%; margin-left: 20px; margin-right: auto;">
<p:panel id="searchFields2" header="Upload Banner Images" style="font-weight:bold; font-size:11px;text-align:left;background-color:#F3F1F6">
<p:fieldset legend="English" toggleable="true" collapsed="true" toggleSpeed="500" style="margin-top: 20px;">
<h:panelGrid columns="2" cellpadding="5">
<p:fileUpload fileUploadListener="#{BannerUpload.uploadEnglishImg}" mode="advanced" dragDropSupport="false" update="messages" sizeLimit="100000" fileLimit="3" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" />
</h:panelGrid>
</p:fieldset>
</p:panel>
</div>
</h:form>
</div>
</ui:define>
</ui:composition>
这个关于 JSF(Primefaces) 应用程序的错误 Spring Boot. 在 uploadimages.xhtml 之后出现此错误,我尝试了很多之前提到的关于堆栈溢出的解决方案,包括 web.xml 基于配置的解决方案,但没有为我工作。
1)UI布局初始化错误-中心面板元素不存在 UI Layout Initialization Error-The center-pane element does not exist
2)Error message
Uploadimages.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition 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"
xmlns:p="http://primefaces.org/ui"
template="maintmplt.xhtml">
<head>
</head>
<ui:define name="content">
<div style="text-align: center;">
<h:form id="search" enctype="multipart/form-data">
<div style="width: 80%; margin-left: 20px; margin-right: auto;">
<p:panel id="searchFields2" header="Banner Images Upload"
style="font-weight:bold; font-size:11px;text-align:left;background-color:#F3F1F6">
<p:fieldset legend="Sinhala" toggleable="true" collapsed="true" toggleSpeed="500" style="margin-top: 20px;">
<p:ajax event="toggle" listener="#{BannerUpload.file}" update="search" />
<h:panelGrid columns="2" cellpadding="5">
<p:growl id="messages1" showDetail="true" />
<h:form enctype="multipart/form-data">
<p:growl id="messages" showDetail="true"/>
<p:fileUpload value="#{BannerUpload.file}" mode="simple" skinSimple="true"/>
<br/>
<ui:fragment rendered="#{not empty BannerUpload.file}">
<img src="data:image/png;base64,#{BannerUpload.imageContentsAsBase64}" />
</ui:fragment>
<br/>
<p:commandButton action="#{BannerUpload.preview}" ajax="false" value="Preview" />
<br/>
<p:commandButton value="Submit" ajax="false" action="#{BannerUpload.upload}" disabled="false"/>
</h:form>
</h:panelGrid>
</p:fieldset>
<p:fieldset legend="English" toggleable="true" collapsed="true" toggleSpeed="500" style="margin-top: 20px;">
<h:panelGrid columns="2" cellpadding="5">
<p:growl id="messages2" showDetail="true" />
<h:form enctype="multipart/form-data">
<p:growl id="engMessages" showDetail="true"/>
<p:fileUpload value="#{BannerUpload.file}" mode="simple" skinSimple="true"/>
<br/>
<ui:fragment rendered="#{not empty BannerUpload.file}">
<img src="data:image/png;base64,#{BannerUpload.imageContentsAsBase64}" />
</ui:fragment>
<br/>
<p:commandButton action="#{BannerUpload.preview}" ajax="false" value="Preview" />
<br/>
<p:commandButton value="Submit" ajax="false" action="#{BannerUpload.upload}" disabled="false"/>
</h:form>
</h:panelGrid>
</p:fieldset>
<p:fieldset legend="Tamil" toggleable="true" collapsed="true" toggleSpeed="500" style="margin-top: 20px;">
<h:panelGrid columns="2" cellpadding="5">
<p:growl id="messages3" showDetail="true" />
<h:form enctype="multipart/form-data">
<p:growl id="tamMessages" showDetail="true"/>
<p:fileUpload value="#{BannerUpload.file}" mode="simple" skinSimple="true"/>
<br/>
<ui:fragment rendered="#{not empty BannerUpload.file}">
<img src="data:image/png;base64,#{BannerUpload.imageContentsAsBase64}" />
</ui:fragment>
<br/>
<p:commandButton action="#{BannerUpload.preview}" ajax="false" value="Preview" />
<br/>
<p:commandButton value="Submit" ajax="false" action="#{BannerUpload.upload}" disabled="false"/>
</h:form>
</h:panelGrid>
</p:fieldset>
</p:panel>
</div>
</h:form>
</div>
</ui:define>
</ui:composition>
由于使用了不受支持的命令按钮,我的示例中出现了上述错误。
<p:commandButton action="#{BannerUpload.preview}" ajax="false" value="Preview" />
将其替换为以下代码并使用 Advanced primefaces fileuploader 而不是简单模式,并根据新实现更改您的 java 控制器。
<p:fileUpload fileUploadListener="#{BannerUpload.uploadEnglishImg}" mode="advanced"
dragDropSupport="false" update="messages2" sizeLimit="100000" fileLimit="1"
allowTypes="/(\.|\/)(png)$/" />
更改了代码示例......
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition 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" xmlns:p="http://primefaces.org/ui" template="maintmplt.xhtml">
<ui:define name="content">
<div style="text-align: center;">
<h:form id="search" enctype="multipart/form-data">
<p:growl id="messages" showDetail="true" />
<div style="width: 80%; margin-left: 20px; margin-right: auto;">
<p:panel id="searchFields2" header="Upload Banner Images" style="font-weight:bold; font-size:11px;text-align:left;background-color:#F3F1F6">
<p:fieldset legend="English" toggleable="true" collapsed="true" toggleSpeed="500" style="margin-top: 20px;">
<h:panelGrid columns="2" cellpadding="5">
<p:fileUpload fileUploadListener="#{BannerUpload.uploadEnglishImg}" mode="advanced" dragDropSupport="false" update="messages" sizeLimit="100000" fileLimit="3" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" />
</h:panelGrid>
</p:fieldset>
</p:panel>
</div>
</h:form>
</div>
</ui:define>
</ui:composition>