1
I have a repeating structure:
<ui:repeat var="item" />
Inside it I print some fields. One of them is the <p:fileUpload/>
So far so good. The problem is time to do the action, when I click the save button it assigns all fields in managebran except the field of file.
But if I remove the fileInput from within the <ui:repeat>
it works.
Besides not working, the attribute of mine bean is void.
<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>
So it 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>
Avoid using ui:repeat, take a look at p:dataList.
– Wakim
Thanks, I’ll take a look and see if it works.
– Tainha
I’ve already fallen into a similar problem (in a datatable). A solution is to leave all the files in a list or array (see this answer from Balusc). It didn’t work for me because the files were optional and I couldn’t do Binding only through the index. What I did at the time was to adapt this Balusc solution to write the results in a Map <ID, File> and adapt the method called in
commandButton
to associate each file to its respective bean (unfortunately I don’t have that code with me, but if funfar I create a response).– Anthony Accioly