I have a code like this:
<ui:repeat value="#{myController.fileList}}" var="element" >
<t:inputFileUpload value="#{myController.uploadedFile[element]}" />
</ui:repeat>
but this returns an error : java.lang.NumberFormatException: For input string: “[0]}”. UploadedFile is an array of Files. When i wrote code like this
...
<t:inputFileUpload value="#{myController.uploadedFile[0]}" />
...
everything is ok, but i want to have there values between 0-8, not only ‘0’, and this has to be returned from my controller. So how to convert this ‘element’ to int value inside <t:inputFileUpload value="#{myController.uploadedFile[element]}" />? Thanks for help.
You can use the
varStatusattribute to obtain the loop status.(only available in JSF 2.x by the way, in JSF 1.x your best bet might be
c:forEach)But why don’t you just use the following?
Update: the
fileListmust be of typeList<Integer>orInteger[]orint[]and theuploadedFilemust be of typeList<SomeObject>orSomeObject[]to get your initial code to work.Update 2: here’s a small reproducible test snippet:
XHTML:
Bean:Works fine here on Mojarra 2.0.3 and Apache Tomcat 6.0.29. You only need to substitute
selectedIndexesasfileListandlistasuploadedFile.