Formular with fileupload

UI Components for JSF
Post Reply
Manu206
Posts: 33
Joined: 25 Mar 2011, 16:15

06 Nov 2011, 17:05

Hi I'm struggling with the fileupload

I have a formular with 2 input fields (title and text) and a fileupload. Now I want to submit the whole form. The result should be a fileupload into a defined directory and a database insert with the image path and the value of the 2 input fields. Sounds very easy ^^

I don't know how to trigger both. The fileupload and the form.

I tried to trigger fileupload via fileuploadlistener but in this case the form will not submit the input fields.
I also tried to submit the form but in this case the fileupload will not be called.
Now I'm totaly frustrated and I really need help from the community.

Code: Select all

<h:form id="form_addinfo" prependId="true" enctype="multipart/form-data" rendered="#{user.loggedIn}">
                        
                        <p:panel id="insert_panel" styleClass="blank_panel" >

                            <p:inputText id="info_add_title" required="true" value="#{add_content.title}" style="width:638px;" maxlength="35">
                                <f:validateLength minimum="10" for="info_add_title" />
                            </p:inputText>
                            <br/>
                            <p:message for="info_add_title"/>
                         
                            <p:editor id="info_add_text" required="true" value="#{add_content.text}" controls="bold italic underline strikethrough bullets numbering" widgetVar="editor" width="650">
                                <f:validateLength minimum="20" for="info_add_text" />
                            </p:editor>
                            <p:message for="info_add_text"/>

                        </p:panel>
                        <h:outputText styleClass="textlabel" value="4. Laden Sie Bilder hoch:"/>
                        <p:fileUpload label=" " fileUploadListener="#{add_content.handleFileUpload}" mode="advanced" showButtons="false"  sizeLimit="1000000" id="fileupload" widgetVar="fileupload" dragDropSupport="true" multiple="true"  allowTypes="/(\.|\/)(gif|jpe?g|png)$/"/>
                        <br/>
<!--
                        <p:commandButton actionListener="add_content.saveInfo" update="insert_panel" ajax="true" styleClass="button_save" />
-->
</h:form>
Is there any example or tutorial to perform something like this. I think fileupload + data is a common use case ?!?
Primefaces 3.5
Mojarra 2.1.9
Netbeans 7.3.x
Glassfish 3.2.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 61 guests