jsf 2 - Get file url in JSF 2.2 -
i trying make openfiledialog in backing bean, can url of local file. seems standard jsf library not support open/save file dialog. there way of getting url of file similar openfiledialog?
here has happen: click on button --> send action backing bean --> show openfiledialog --> url of file --> add url of file list of strings.
i not sure how accomplish bold steps above. there can give me leads or accomplish this?
(i using jsf & primefaces, prefer not use external library if possible.)
since you're using jsf 2.2 primefaces, why not use primefaces component itself?
below primefaces 5.0 showcase example basic file upload:
<h:form enctype="multipart/form-data"> <p:growl id="messages" showdetail="true" /> <p:fileupload value="#{fileuploadview.file}" mode="simple" skinsimple="true"/> <p:commandbutton value="submit" ajax="false" actionlistener="#{fileuploadview.upload}" disabled="true" /> </h:form>
managed bean
import org.primefaces.event.fileuploadevent; import org.primefaces.model.uploadedfile; @managedbean public class fileuploadview { private uploadedfile file; public uploadedfile getfile() { return file; } public void setfile(uploadedfile file) { this.file = file; } public void upload() { if(file != null) { facesmessage message = new facesmessage("succesful", file.getfilename() + " uploaded."); facescontext.getcurrentinstance().addmessage(null, message); } } }
the enctype
attribute form required. also, using primefaces file upload, need setup context parameters , filters. may refer appropriate documentation same.
Comments
Post a Comment