Help with fileupload in java ee 7 xhtml, get n files uploaded

0

I hope you can help me with this.

I'm with a web app in java ee 7 primefaces like the view and the corresponding Beans.

What I want is the following:

By selecting a particular category, requirements are generated dynamically and next to them, a FileUpload is added, meaning that each requirement must upload a file. The view correctly renders each requirement with its FileUpload, what I want to do is save those files that are uploaded with the id of the corresponding requirement.

Primefaces gives me the basic fileupload see here code , but when sending the id of the requirement, by submit, I do not receive in the corresponding bean.

While with this fileupload of primefaces same see here , I can not send the corresponding parameter, I do not know how I could overwrite that method (the one with the fileuploadevent) to send the id of the requirement right there.

I hope you can help me ...

    
asked by Carlos Vega 28.10.2016 в 20:45
source

1 answer

0

A form is being used to send the information to the server, so you can attach more components and assign them to a property in your managed bean:

<h:form enctype="multipart/form-data">

    <p:fileUpload value="#{bean.file}" mode="simple" skinSimple="true"/>

    <h:inputHidden value="#{bean.id}" />

    <p:commandButton value="Submit" ajax="false" actionListener="#{fileUploadView.upload}" disabled="true" />
</h:form>

If the information is generated dynamically, I assume you may be using Js for this procedure and with js you can assign the id that corresponds to each new component of fileUpload .. .

    
answered by 09.11.2016 в 17:18