0

I'm using primefaces library in my application. I need change users picture on click by image. Can I hide primefaces file uploader component and work with it with javascript? I.E. can I use it from javascript like in following code?

fileUploader.openFile();
fileUploader.sendFile();

Any suggestions?

2 Answers 2

1

To choose a file:

fileUploader.cfg.fileInput.click()
0

In the Primefaces show case there is FileUpload example, which is looks like what you are asking for:

<p:fileUpload widgetVar="uploader" height="48" width="48"  
    fileUploadListener="#{fileUploadController.handleFileUpload}"  
    image="/images/browse.png" cancelImage="/images/cancel.png"  
    allowTypes="*.jpg;*.png;*.gif;" description="Images" customUI="true"/>  

<h:outputLink value="#" title="Upload" onclick="uploader.upload();"   
    style="font-weight:bold;color:#616D7E">  
    Upload Files  
</h:outputLink>

It's implemented in flash. I don't know, if there are html5 alternatives.
You may also try autoupload attribute(auto="true") instead of using link. Please, let me know, if you get it working.

1
  • are you able to use javascript api for primefaces 3.0.M4 ? I'm struggling with this for a while.
    – baraber
    Nov 17, 2011 at 20:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.