Reputation: 399
I need to upload file ajax so that I can show the name of uploaded file but without adding any jar files like primefaces, richfaces.
My form is inside dialog box where I have an upload button which should call a method by ajax. My code is something like this...
<h:commandButton value="Upload" action="#{bean.uploadMethod}">
<f:ajax listener="#{bean.abcMethod}" event="click"/>
</h:commandButton>
and I would also like to know if I can just browse, keep the name of file in some list to show and then I can submit my whole form. This submission should also upload those files which I have shown the name in list. Is it possible?
Upvotes: 3
Views: 1459
Reputation: 10463
Primefaces offers the FileUpload component which is a fully AJAX enabled file upload JSF component.
I am not complete sure how it works but I believe it utilizes modern browser features through HTML5. This functionality of course requires that the client be a modern browser that can understand HTML5 markup.
Upvotes: 0
Reputation: 20339
I'm also struggling with uploading files (images) through AJAX. I've looked for several methods and how companies like Google or Dropbox implemented this.
So far I found two methods:
iframe
to submit the file. This isn't actually AJAX, so it works in most browsers. However I have yet to see an implementation (other than PrimeFaces') in JSF.If you want a quick solution you can use primefaces, richfaces (and probably icefaces). But you already said you didn't want to use one of those.
Maybe someone is nice enough to post a real solution here, but I thought I'd throw in an idea or two. ;-)
Upvotes: 2