UI布局初始化错误-中心窗格元素不存在,中心窗格为必填元素

时间:2018-12-13 06:37:07

标签: jquery spring-boot jsf xhtml

关于带有Spring Boot的JSF(Primefaces)应用程序的错误。 继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>

1 个答案:

答案 0 :(得分:0)

由于不支持的命令按钮用法,在我的示例中发生了上述错误。

   <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>