File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes upload file jsf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "upload file jsf" Watch "upload file jsf" New topic

upload file jsf

Dura Hurtado
Ranch Hand

Joined: Feb 16, 2011
Posts: 120
I am trying to upload a file using primefaces the code is the next one:

<p:fileUpload fileUploadListener="#{fileUploadController.handleFileUpload}"
allowTypes="*.jpg;*.png;*.gif;" description="Images"/>

public class FileUploadController {

private Logger logger = LoggerFactory.getLogger(FileUploadController.class);

public void handleFileUpload(FileUploadEvent event) {"Uploaded: {}", event.getFile().getFileName());

FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
FacesContext.getCurrentInstance().addMessage(null, msg);

┬┐is it right or it incorrect?

I agree. Here's the link:
subject: upload file jsf
It's not a secret anymore!