0

When I use primefaces file upload in a standard page, everything works fine. But when this is added in an included page fileupload event never calls

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

Dynamically included page loaded on tree node click is as follows

<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>
AWAIS
  • 1
  • 1
  • "*Something goes wrong.*" What then? Please elucidate the cause of "*Not working*" precisely at length. – Tiny Jul 15 '15 at 06:20
  • On tree node click the center layout unit loaded the page that contains fileupload component. It browses the file perfectly but when I click on upload button nothing happens, in fact bean never calls – AWAIS Jul 15 '15 at 06:28
  • To exclude one and other, if that include contained a regular command button, does it call the backing bean method or also not? If not, then this is not specifically related to file upload. One of those two dupes must then help you further: http://stackoverflow.com/questions/8875818/how-to-use-primefaces-pfileupload-listener-method-is-never-invoked or http://stackoverflow.com/questions/2118656/commandlink-commandbutton-ajax-backing-bean-action-listener-method-not-invoked/ – BalusC Jul 15 '15 at 07:15
  • Please look at the code chunk above when I added the file upload component in the standalone page it is working perfectly, but when i included it inside ui:composition the bean even never fires. – AWAIS Jul 15 '15 at 07:23
  • @BalusC you are right I tried to add a command button into the included page but it is also not calling the bean. Kindly guide me about the mistake. I have p:tree in the left layout unit and I want to load the file upload page in the center layout on click of tree node – AWAIS Jul 15 '15 at 07:35
  • @BalusC I have checked and verified everything you suggested, waiting for guidelines from your side – AWAIS Jul 15 '15 at 08:32

0 Answers0