0

I'm using Primeface 5.0, Glassfish 4. Within this dialog I'm displaying a list of document, which can be attached to the dataset. The fileupload is working and the action-routine of the upload-button is fired to store the uploaded file. But after the action-routine of the command-button is finished, the datalist is refreshed and dialog is closed, but it shouldn't. The "remove" button work fine and refresh the datalist.

DlgVArEntryEdit.xhtml:

<!DOCTYPE html>
<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:p="http://primefaces.org/ui"
  xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition>
    <p:dialog id="VArEntryViewDlg" 
              widgetVar="VArEntryViewDialog" 
              resizable="false"
              showEffect="fade" 
              hideEffect="explode"
              modal="true"
              header="Buchung">
        <h:form id="VArEntryViewDlgFrm" enctype="multipart/form-data">
            <p:panelGrid  rendered="#{arEntryController.selected != null}">

                <p:row>
                    <p:column><p:outputLabel value="Buchungs-ID:"/></p:column>
                    <p:column><p:outputLabel value="#{arEntryController.selected.arEntryId}" /></p:column>
                </p:row>
                <p:row>
                    <p:column><p:outputLabel value="Buchnungs-No:"/></p:column>
                    <p:column><p:outputLabel value="#{arEntryController.selected.entryNo}" /></p:column>
                </p:row>
                <p:row>
                    <p:column><p:outputLabel value="Storniert :"/></p:column>
                    <p:column><p:selectBooleanCheckbox value="#{arEntryController.selected.isCancelled}" /></p:column>
                </p:row>
                <p:row>
                    <p:column><p:outputLabel value="Buchnugsreferenz"/></p:column>
                    <p:column><p:outputLabel value="#{arEntryController.selected.receiptNo} / #{arEntryController.selected.receiptType}"/></p:column>
                </p:row>
                <p:row>
                    <p:column><p:outputLabel value="#{bundle.entryCode}"/></p:column>
                    <p:column><p:outputLabel value="#{arEntryController.selected.entryCodeName}"/></p:column>
                </p:row>
                <p:row>
                    <p:column><p:outputLabel value="Datum"/></p:column>
                    <p:column><p:calendar value="#{arEntryController.selected.entryDate}" size="10" pattern="dd.MM.yyyy" showOn="button"/></p:column>
                </p:row>
                <p:row>
                    <p:column><p:outputLabel value="#{bundle.entryText}"/></p:column>
                    <p:column><p:inputText value="#{arEntryController.selected.entryData}" size="100"/></p:column>
                </p:row>
                <p:row>
                    <p:column><p:outputLabel value="#{bundle.Comment}"/></p:column>
                    <p:column><p:inputTextarea rows="5" cols="100" value="#{arEntryController.selected.entryComment}"/></p:column>
                </p:row>
                <p:row>
                    <p:column colspan="2">
                        <h:panelGroup id="uploadDataListId">
                            <p:dataTable id="UploadDatalist" 
                                         value="#{arEntryController.documents}" 
                                         var="item"
                                         selection="#{arEntryController.documentSelected}"
                                         rowKey="#{item.documentId}"
                                         style="width: 400px"
                                         >
                                <p:column headerText="#" style="width: 5%; text-align: center">
                                    <p:outputLabel value="#{item.documentId}"/>
                                </p:column>
                                <p:column headerText="#{bundle.DocumentName}" style="text-align: left">
                                    <p:outputLabel value="#{item.documentName}"/>
                                </p:column>
                                <p:column style="width:7%;text-align: center">
                                    <p:commandButton update=":VArEntryViewDlgFrm:UploadDatalist" 
                                                     action="#{arEntryController.removeDocument}" 
                                                     icon="ui-icon-trash" 
                                                     title="Löschen" 
                                                     process="@this">
                                        <f:setPropertyActionListener value="#{item}" target="#{arEntryController.documentSelected}" />
                                    </p:commandButton>
                                </p:column>
                            </p:dataTable>
                            <p:fileUpload id="fileUploadId" value="#{arEntryController.file}" mode="simple" />
                            <p:commandButton update=":VArEntryViewDlgFrm:uploadDataListId" 
                                             process=":VArEntryViewDlgFrm:fileUploadId"
                                             actionListener="#{arEntryController.upload}"
                                             ajax="false"
                                             value="Upload"/>
                        </h:panelGroup>
                    </p:column>
                </p:row>
                <p:row>
                    <p:column><p:outputLabel value="geladene #{bundle.DocumentCount}"/></p:column>
                </p:row>
                <p:row>
                    <p:column><p:outputLabel value="Netto"/></p:column>
                    <p:column><p:inputText value="#{arEntryController.selected.amountNet}">
                                <f:convertNumber currencySymbol="€" groupingUsed="true"
                                         maxFractionDigits="2" type="currency" />
                            </p:inputText></p:column>
                </p:row>
                <p:row>
                    <p:column><p:outputLabel value="USt-Code"/></p:column>
                    <p:column><p:inputText value="#{arEntryController.selected.GSTName}"/></p:column>
                </p:row>
                <p:row>
                    <p:column><p:outputLabel value="USt"/></p:column>
                    <p:column><p:inputText value="#{arEntryController.selected.amountGst}">
                                    <f:convertNumber currencySymbol="€" groupingUsed="true"
                                         maxFractionDigits="2" type="currency" />
                                </p:inputText></p:column>
                </p:row>
                <p:row>
                    <p:column><p:outputLabel value="Brutto"/></p:column>
                    <p:column><p:inputText value="#{arEntryController.selected.amountTotal}">
                                <f:convertNumber currencySymbol="€" groupingUsed="true"
                                         maxFractionDigits="2" type="currency" />
                            </p:inputText></p:column>
                </p:row>
            </p:panelGrid>
            <p:commandButton value="#{bundle.Cancel}" 
                             style="float:right;" 
                             process="@this" 
                             actionListener="#{arEntryController.closeDlg}" 
                             update=":formCenter :growl"
                             onclick="PF('VArEntryViewDialog').hide()"/>
            <p:commandButton value="#{bundle.Delete}" 
                             style="float:right;" 
                             process="@this" 
                             actionListener="#{arEntryController.remove}" 
                             update=":formCenter :growl"
                             oncomplete="PF('VArEntryViewDialog').hide()"/>
            <p:commandButton value="#{bundle.Change}" 
                             style="float:right;" 
                             actionListener="#{arEntryController.updateEntry}" 
                             update=":formCenter :growl"
                             oncomplete="PF('VArEntryViewDialog').hide()"/>
        </h:form>
    </p:dialog>
    </ui:composition>
</html>

I have no idea, why the upload-button closes the dialog and the remove-button not. What is wrong here?

Nik
  • 53
  • 1
  • 9
  • Your fileUpload button has ajax="false". You may change it to ajax request, but then keep in mind http://stackoverflow.com/questions/19262356/file-upload-doesnt-work-with-ajax-in-primefaces-4-0-running-on-jsf-2-2-x and http://stackoverflow.com/questions/19996774/proble-with-ajax-true-in-pfileupload-with-mode-simple-not-working – Aneta Stępień Jun 06 '14 at 22:44
  • I tried them, but with no luck. I will do it in a page, Dialog and fileupload will not fit together. thx Nik. – Nik Jun 07 '14 at 15:35
  • `ajax=false` is necessary when using `fileUpload`. But without using of ajax your whole page gets reloaded after request, which means `dialog` will be closed. So like you already realized `fileUpload` plus `dialog` is a bad combination. – LarsBauer Jun 07 '14 at 16:06

0 Answers0