0

I have a page layout with p:layout tag. I load from the "west" unit, where my navigation is defined, dynamically the content pages.

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

And a page for file uploading:

upload.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 />

There is a strange behaviour: The loading of the content pages like upload.xhtml works as expected but if i try to uplade a file (ore more) it won't work, the bean will not called. If i try it a second time, then it works ?????

If i replace the f:ajax component in index.xhtml and the h:commandLink components with a h:commandButton with the update=":centerContentPanel" then the file upload works also as expected. But i don't want to have commandButtons.

How can i fix this that i can work with commandLinks?

Thanks in advance

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
piet
  • 376
  • 1
  • 5
  • 17
  • If this is a duplicate, please post the link to the existing question. – piet Aug 26 '16 at 06:47
  • Unfortunately your approach, mentioned in the origin post won't work for me. Same beahviour. I think the prob is that the form which handles the fileupload will load some js files and gets a 304 for that. – piet Aug 26 '16 at 08:06
  • UPDATE: the solution was indeed to include some JS methods as in http://stackoverflow.com/questions/11408130/hcommandbutton-hcommandlink-does-not-work-on-first-click-works-only-on-second described. – piet Aug 26 '16 at 08:39

0 Answers0