i'm new in java & jsf framework. I have a situation and make me realy confused. I'm trying to create upload form in jsf, the backing bean is request scoped, user must login for using this form. when I test to submit form, the validation message its not appear, the form just refresh without any validation/required message. I try to find the answer in google or stackoverflow but it not works. However i can upload my files when i try create simple application like my form below, without login function.
My form is look like this:
<h:form id="frMember" enctype="multipart/form-data">
<h:inputText id="username" value="#{memberForm.email}" required="true" requiredMessage="username_required_message" pt:placeholder="username"/><br/><br/>
<h:inputFile value="#{memberForm.fileFoto}" required="true" requiredMessage="file_required_message"/><br/>
<h:commandButton value="upload" action="#{memberForm.upload()}" class="btn btn-danger"/>
</h:form>
I'm using glassfish 4, JSF 2.2.7, Netbeans 8 and i'm not used 3rd party like tomahawk fileupload. I also have try googling and searching through stackoverflow for solving my problem, but still i can't solved it.
updated
this is my controller
public class MemberFormView implements Serializable {
private Part fileFoto;
/**
* Creates a new instance of MemberFormView
*/
public MemberFormView() {
}
public void upload() throws IOException {
String fileName = FilenameUtils.getName(fileFoto.getName());
String contentType = fileFoto.getContentType();
try (InputStream input = fileFoto.getInputStream()) {
Files.copy(input, new File("/var/AppFile/tmp/", fileFoto.getName()).toPath());
}
}
}
and this is my faces-config.xml
<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
<managed-bean>
<managed-bean-name>memberForm</managed-bean-name>
<managed-bean-class>controller.member.MemberFormView</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>