Show messages with Fileupload

UI Components for JSF
Post Reply
Erates
Posts: 11
Joined: 16 Jul 2015, 09:43

16 Jul 2015, 10:06

Hey,

I have a dialog that has a fileupload (basic) inside it. Because this, the dialog is in a seperate form, with enctype="multipart/form-data". I have my p:commandButton on ajax="false". When I fill everything in, the form is posted like it should and the file is uploaded.

Code: Select all

<h:form enctype="multipart/form-data">
            <p:dialog widgetVar="newMessageDialog" header="NEW MESSAGE" styleClass="message-detail-window" modal="true" draggable="false" closeOnEscape="true" resizable="false" hideEffect="fade" showEffect="fade" style="min-width: 800px;" >
                <p:messages for="dialogMessages" autoUpdate="true" showDetail="true" showSummary="false" />
                <p:panelGrid columns="2" styleClass="ui-panelgrid-blank">

                    <h:outputLabel value="#{messaging_msg.mimetype}" />
                    <p:inputText value="#{uploadBean.mimeType}" styleClass="clean-border" style="margin-bottom: 0px;" />

                    <h:outputLabel value="FILE" />
                    <p:fileUpload value="#{uploadBean.uploadedFile}" mode="simple" skinSimple="true" label="BROWSE" />

                    <h:outputLabel value="#{messaging_msg.password}" />
                    <p:password value="#{uploadBean.password}" styleClass="clean-border" />

                    <h:outputLabel value="" />
                    <p:commandButton value="SEND" styleClass="button success dialogButton" ajax="false" actionListener="#{uploadBean.handleFileUpload()}" style="float: right;" />
                </p:panelGrid>
            </p:dialog>
        </h:form>
Now the other values (mimetype and password) should be validated aswell, and they are, but after the form is posted. Meaning, the dialog is closed and the page refreshed, removing the messages.

My question: is there a way to validate the inputs, and show the validation message, without posting the form? That way, the dialog isn't closed and the messages are shown.
JSF 2.2
Primefaces 5.3
Payara 4.1.1.171

chrishj
Posts: 229
Joined: 11 Jul 2011, 21:58
Location: England, Lancashire
Contact:

16 Jul 2015, 15:40

Have you considered using RequestContext within the ActionListener method to close the dialog if the user input is correct?
PrimeReact: 9.6.0
NextJs: 13.4.12
Theme Apollo v9.0
Database pg 8.8.0
react-hook-form: 7.38.0

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 32 guests