I’ve been trying to use the new h:inputFile from JSF 2.2, but I cannot get it to work. Ever since I have changed the “enctype” attribute of the “h:form” tag, the action is not being invoked anymore.
I have stripped my application from all Filters and web libraries, but it still does not work.
Here are file contents to make it clearer:
The web.xml:
<?xml version="1.0" encoding="utf-8"?>
<web-app 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-app_3_1.xsd"
version="3.1">
<context-param>
<param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>facelets.LIBRARIES</param-name>
<param-value>/WEB-INF/soupsocial.taglib.xml</param-value>
</context-param>
</web-app>
The faces-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config 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"
version="2.2">
<lifecycle>
<phase-listener>org.dejava.service.soupsocial.DebuggerPL</phase-listener>
</lifecycle>
</faces-config>
The form fragment:
<h:form enctype="multipart/form-data">
<h:inputFile id="file" value="#{newProjectIdeaController.displayImage}" />
<h:message for="file" />
<h:commandButton value="Upload" action="#{newProjectIdeaController.createProject()}" />
</h:form>
And the managed bean:
@ConversationScoped
@SoupSocialCtx
@Named("newProjectIdeaController")
public class NewProjectIdeaController extends AbstractNewProjectController implements Serializable {
/**
* The display image for the project.
*/
private Part displayImage;
// Getter/setter
/**
* @see org.dejava.service.soupsocial.controller.philanthropy.AbstractNewProjectController#createProject()
*/
public void createProject() throws IOException {
...
}
}
I have created a phase listener in order to debug the request, and the request goes directly from RestoreView to the RenderResponse phase.
Any ideas on how to solve this?
P.S.: I am using WildFly 8.0.0.Alpha4.
Updating the version solved it. I am using WildFly 8.0.0.Final.