0

I am using primefaces p:fileUpload in simpleMode. When I upload any file in the frontend, I see null for the file upload in the bean side(backing side). You can see the sample code below. I would be glad if you can help me .

Sample Code:

<h:form id="welcomeForm">
<p:fileUpload value="#{hashRaporBean.file}" mode="simple" />
<h:commandButton value="Submit" action="#{hashRaporBean.upload}" ajax="false" />
<h:message for="welcomeForm" />

Bean Code :

@ManagedBean(name = HashRaporBean.BEAN_NAME)
@ViewScoped
public class HashRaporBean implements Serializable {
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() + " is uploaded.");
        FacesContext.getCurrentInstance().addMessage(null, message);
    }
}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Tonyukuk
  • 5,745
  • 7
  • 35
  • 63

1 Answers1

0

I dont very well known about h taglib, May be because of encrypt not added

<h:form id="welcomeForm" enctype="multipart/form-data" >

same as , click here

PSabuwala
  • 155
  • 1
  • 9
  • Hello Parth. It does not change even I add encytpe. I come across with the same error . Do you think ui:define or ui:composition neutralize this issue ? – Tonyukuk Sep 23 '16 at 08:45
  • Nope, i can not find any solution for this. i hope link provided in answer helps you. thnx – PSabuwala Sep 26 '16 at 09:47