I have a primefaces panel, where I want to offer primefaces' p:fileUploader
for several elements. During runtime it is not clear, how many items there will be. This is my code:
<h:form>
<p:panel id="grid" header="">
<h:panelGrid columns="2" cellpadding="5">
<c:forEach items="${bean.testCurrent}"
var="car" varStatus="i">
<p:outputLabel value="#{car.name}: " for="image${i.index}" />
<p:column>
<p:fileUpload id="image${i.index}"
fileUploadListener="#{bean.uploadImage}"
mode="advanced" dragDropSupport="true" multiple="false"
update="messages" sizeLimit="1000000"
allowTypes="/(\.|\/)(gif|jpe?g|png)$/"
oncomplete="disableChoosing()"/>
<p:growl id="growl" showDetail="true" />
</p:column>
</c:forEach>
</h:panelGrid>
<p:commandButtonaction="#{bean.save()}" value="Save" />
<p:commandButton action="#{bean.cancel()}" value="Cancel" />
</p:panel>
</h:form>
So my first step was trying it with JSTL's c:forEach
. This doesn't work, because JSTL runs during build time of the view and JSF runs during render time of the view component tree.
Is there a possibility to implement a for-loop in the panel or is there any other possibility to display the form elements dynamically?