PrimeFaces的FileUpload在动态加载的页面内不起作用

时间:2015-07-15 05:56:24

标签: jsf primefaces jsf-2.2 java-ee-7

当我在标准页面中使用primefaces文件上传时,一切正常。但是当在包含的页面中添加它时,fileupload事件永远不会调用

`<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <f:view contentType="text/html">
        <h:head>
            <f:facet name="first">
                <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
                <title>EMR</title>
            </f:facet>

            <style type="text/css">      

            </style>
            <script type='text/javascript' src="">
            </script> 

        </h:head>
        <h:body>
            <p:layout fullPage="true" id="p_layoutid" style="border:0px;">

                <p:layoutUnit position="north" id="top" size="65" collapsible="true" gutter="0" style="border:0px;">
                    <h:form id="frmtheme">                        
                        <p:themeSwitcher effectSpeed="normal" effect="fold" style="width:160px;" 
                                         id="defaultSwitcher" value="#{themeSwitcherView.themeName}">

                            <f:selectItem itemLabel="Choose Theme" itemValue="" />
                            <f:selectItems value="#{themeSwitcherView.themes}" />        
                            <p:ajax global="false" listener="#{themeSwitcherView.saveTheme}" />

                        </p:themeSwitcher>
                    </h:form>   

                </p:layoutUnit>

                <p:layoutUnit position="west" size="300" collapsible="true" gutter="0" style="border:0px;">
                    <h:form id="frmtree"  >
                        <p:growl id="messages" showDetail="true" />  
                        <p:tree value="#{treeBean.root}" var="node"   style="border:0px;"
                                selectionMode="single"  selection="#{treeBean.selectedNode}" id="tree"

                                >  

                            <p:ajax event="expand" update=":frmtree:messages" listener="#{treeBean.onNodeExpand}" />  
                            <p:ajax event="collapse" update=":frmtree:messages" listener="#{treeBean.onNodeCollapse}" />  

                            <p:ajax event="select" update=":centerContentPanel" listener="#{treeBean.onNodeSelect}"  />  
                            <p:ajax event="unselect" update=":frmtree:messages" listener="#{treeBean.onNodeUnselect}" />  

                            <p:treeNode>  
                                <h:outputText value="#{node}" />
                            </p:treeNode>  
                        </p:tree>                        
                    </h:form>
                </p:layoutUnit>
                <p:layoutUnit id="cent" position="center"
                              resizable="true" closable="true" collapsible="true" style="border:0px;">

                    <h:panelGroup id="centerContentPanel" rendered="true" >  
                        <ui:include id="maincontent"  src="#{treeBean.pageName}" ></ui:include>                    
                    </h:panelGroup>

                </p:layoutUnit>

            </p:layout>
        </h:body>
    </f:view>
</html>`

在树节点单击上加载的动态包含页面如下

<ui:composition 
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"
    >
    <h:form id="upForm" target="_blank" >   

        <p:fileUpload fileUploadListener="#{fileUp.handleFileUpload}" 
                      mode="advanced"
                      update="messagesup"
                      multiple="true"

                      sizeLimit="20971520"
                      label="Select File"
                      allowTypes="/(\.|\/)(gif|jpe?g|png|pdf|doc?x)$/"/>
        <p:growl id="messagesup" showDetail="true"/>  



    </h:form>
</ui:composition>

0 个答案:

没有答案