Reputation: 2214
the problem is with file uploader from primefaces web.xml
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
.xhtml
</h:form>
...
</h:form>
<h:form enctype="multipart/form-data">
<p:fileUpload value="#{contratosMB.fileContrato}" mode="simple"/>
<p:commandButton value="Submit" ajax="false"
actionListener="#{contratosMB.upload}" update=":form2:formgen:growl"/>
</h:form>
contratosMB.java
public void upload() {
if(fileContrato != null) {
JsfUtil.addSuccessMessage("Se ha cargado correctamente el archivo: " + fileContrato.getFileName());
}
}
I was read some question like this, but nothing was help me... i was add commons-fileupload and commons-io to the project, but dont work not go inside upload method, dont send exception.
Upvotes: 1
Views: 1598
Reputation: 382
Nesting 'form' elements is illegal. Try to upload file in advanced mode and use FileUploadListener to access FileUploadEvent and data.
Upvotes: 0
Reputation: 2214
it working creating and editing faces-config:
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId> commons-fileupload</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId> commons-io</artifactId>
<version>1.4</version>
</dependency>
but dont work full for me because form uploader is inside to other form...
<h:form>
...
<h:form enctype="multipart/form-data">
<p:messages showDetail="true"/>
<p:fileUpload value="#{contratosMB.fileContrato}" mode="simple"/>
<p:commandButton value="Submit" ajax="false"
actionListener="#{contratosMB.upload}"/>
</h:form>
</h:form>
any body can tell me why??
Upvotes: 0
Reputation: 2967
Try changing
actionListener="#{contratosMB.upload}"
to
action="#{contratosMB.upload}"
.
Check this out : Differences between action and actionListener
Upvotes: 1