FileUnput PrimeFaces does not update the attribute;

1

I have a repeat structure:

<ui:repeat var="item" />

Inside it I print some fields. One of them is <p:fileUpload/>

So far so good. The problem is when it's time to do the action, when I click the save button it assigns all the fields in managebran minus the file field.

But if I remove the fileInput from within <ui:repeat> it works.

In addition to not working, the attribute of my bean is null.

<h:form>
<ui:repeat var="item" value="#{bean.page.columns}">
<p:fileUpload mode="simple" value="#{bean.file}" />
</ui:repeat>
<p:commandButton ajax="false" action="#{bean.save}" value="#{msgs.save}" 
 update="growl" styleClass="btn button" />
</h:form>

This works, it associates the value in my bean .

<h:form>
<p:fileUpload mode="simple" value="#{bean.file}" />
<p:commandButton ajax="false" action="#{bean.save}" value="#{msgs.save}" 
 update="growl" styleClass="btn button" />
</h:form>
    
asked by anonymous 31.07.2014 / 19:20

1 answer

2

Your form is using the default enctype that is application/x-www-form-urlencoded , to handle POST requests involving binaries, that in the case of a file upload, it is necessary to use a specific enctype: multipart/form-data

configure your form this way:

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

To upload multiple files, you can use the multiple="true" attribute on your p:fileUpload

    
11.08.2014 / 22:04