I’m using the component rich:fileUpload for uploading files to my server the problem is that those files go along with a form that the user fills, so I wanna use one external button for doing this.
The user select the files to upload, fill the form and then click a “Submit” button at the bottom of the page. This upload the file with the form. I’ve tried it like this:
I’m able to hide the button inside the panel of fileUpload so the user don’t click on it.
<rich:fileUpload id="fileUploadId"
style="width: 100%; height: 130px;"
fileUploadListener="#{documentsBean.listener}"
maxFilesQuantity="1"
uploadButtonClass="display-none"
uploadButtonClassDisabled="display-none">
</rich:fileUpload>
And what I’ve tried with the button is
<a4j: commandButton id="uploadFormButton"
value="Attach"
onclick="#{rich:component('fileUploadId')}.submitForm();"
oncomplete="#{rich:component('fileUploadId')}.clear(); return false;"/>
But it doesn’t work.
I don’t know if there is a way to do exactly what you want, but here is another solution you can use :
and the bean :
Hope this helps!