• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

upload file jsf

Dura Hurtado
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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) {
logger.info("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?

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic