0

我有一个带有 p:layout 标签的页面布局。我从定义导航的“西”单元动态加载内容页面。

索引.xhtml:

<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"
xmlns:p="http://primefaces.org/ui">
<h:head>
    <title>upload</title>
</h:head>

<h:body>
    <p:layout fullPage="true">

        <p:layoutUnit position="north" size="130"  resizable="false" closable="false" collapsible="false">
            <h:graphicImage value="resources/image.png" styleClass="logo" />
        </p:layoutUnit>

        <p:layoutUnit position="west" size="150" resizable="false" closable="false" collapsible="false">
           <h:form id="form2">
               <f:ajax render=":centerContentPanel" execute="@this">
                   <li><h:commandLink value="My Data" action="#{navigationBean.doNav('mydata')}" /></li>
                   <li><h:commandLink value="Upload" action="#{navigationBean.doNav('upload')}" /></li>
                </f:ajax>
            </h:form>
        </p:layoutUnit>

        <p:layoutUnit id="cent" position="center" resizable="false" closable="false" collapsible="false">
                <h:panelGroup id="centerContentPanel">
                    <ui:include src="#{navigationBean.pageName}.xhtml" />
                </h:panelGroup>
        </p:layoutUnit>

        <p:layoutUnit position="south" size="60"  resizable="false" closable="false" collapsible="false">
        </p:layoutUnit>

    </p:layout>
</h:body>

还有一个文件上传页面:

上传.xhtml

<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://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">

<h:form enctype="multipart/form-data">
    <p:fileUpload value="#{fileUploadView.file}" fileUploadListener="#{fileUploadBean.handleFileUpload}" mode="advanced" dragDropSupport="false"
                  multiple="true" update="@this" sizeLimit="100000" fileLimit="3" />

    <p:growl id="messages" showDetail="true" />
</h:form>   
<br />

有一个奇怪的行为:像 upload.xhtml 这样的内容页面的加载按预期工作,但是如果我尝试升级一个文件(或更多),它将不起作用,bean 将不会被调用。如果我第二次尝试它,那么它可以工作??????

如果我用 update=":centerContentPanel" 将 index.xhtml 中的 f:ajax 组件和 h:commandLink 组件替换为 ah:commandButton ,那么文件上传也会按预期工作。但我不想有命令按钮。

我该如何解决这个我可以使用 commandLinks 的问题?

提前致谢

4

0 回答 0