rich:fileUpload is not invoking the listener class
k.venkat1912 Aug 18, 2014 2:17 PMHello All
I am using richfaces 3.3.1 with seam2.2.2. and I am trying to invoke the listener method in the backend class using the rich:fileupload tag from the xhtml file. But for some reason the listener method is not getting invoked. Could anyone please help. Below is the code. I am also attaching the related files.
Listener method
public void multiUploadListener(UploadEvent event) throws Exception{
FacesUtils.addInfoMessage("Inside Test.multiUploadlistener method");
this.event = event;
// List<UploadItem> items = null;
try{
// items = event.getUploadItems();
UploadItem item = event.getUploadItem();
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! event.isMultiUpload "+event.isMultiUpload());
int i = 1;
String name = "unnamed_attachment";
// for(UploadItem item: items){
if(item.getData() != null && item.getData().length >0){
FileUploadAttachment fua = new FileUploadAttachment();
if(item.getData().length > 50000){
String pload = new String(item.getData(),0,50000);
fua.setData(pload.getBytes());
fua.setSize(pload.length());
}else{
fua.setData(item.getData());
fua.setSize(item.getData().length);
}
if(item.getContentType() != null){
fua.setContentType(item.getContentType());
}
if(item.getFileName() != null){
fua.setName(item.getFileName());
}else{
fua.setName(name +"_"+i);
i++;
}
uploadAttachments.add(fua);
}
// }
}catch(Exception ex){
FacesUtils.addErrorMessage("Error occured in loading multiple files from UploadEvent : "+ex.getMessage());
}
}
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
<rich:modalPanel id="#{multimodalId}" height="200" width="640">
<f:facet name="header">#{multi_modalHeader}</f:facet>
<f:facet name="controls">
<h:panelGroup>
<h:commandButton value="X" onclick="Richfaces.hideModalPanel('#{multimodalId}'); return false;"/>
</h:panelGroup>
</f:facet>
<h:form>
<rich:fileUpload id="multiUpload" uploadData="#{handler.uploadAttachments}" fileUploadListener="#{handler.multiUploadListener}"
immediateUpload="true" maxFilesQuantity="5" acceptedTypes="*" allowFlash="true">
</rich:fileUpload>
<h:panelGrid columns="2">
<h:commandButton type="submitMultiples" value="SendData" action="#{handler.processMultiples(handlevalue)}"/>
</h:panelGrid>
</h:form>
</rich:modalPanel>
</ui:composition>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>TestFacilityWeb</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.seam</url-pattern>
</servlet-mapping>
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>enable</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>#{skinBean.currentSkin}</param-value>
</context-param>
<listener>
<listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
</listener>
<filter>
<filter-name>Seam Filter</filter-name>
<filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
<init-param>
<param-name>createTempFiles</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>maxRequestSize</param-name>
<param-value>100000000</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Seam Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Seam Resource Servlet</servlet-name>
<servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
</servlet>
<servlet>
<description>This one Streams an Image from an Encrypted String</description>
<display-name>ImageStreamerServlet</display-name>
<servlet-name>ImageStreamerServlet</servlet-name>
<servlet-class>servlets.ImageStreamerServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ImageStreamerServlet</servlet-name>
<url-pattern>*.image</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Seam Resource Servlet</servlet-name>
<url-pattern>/seam/resource/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<security-constraint>
<display-name>Restrict raw XHTML Documents</display-name>
<web-resource-collection>
<web-resource-name>XHTML</web-resource-name>
<url-pattern>*.xhtml</url-pattern>
</web-resource-collection>
<auth-constraint/>
</security-constraint>
</web-app>
-
rich_fileupload_notworking.zip 12.3 KB