MultipartRequest handling after upload invoked by applet
lacino25 Nov 16, 2009 8:50 PMHello !
I'm trying to handle MultipartRequest after upload invoked by Jumploader applet. This applet's providing multi files uploading.
So here is my scenario:
My snippet of ScanHome.xhtml:
<!-- JumpLoader --> <applet name="jumpLoaderApplet" code="jmaster.jumploader.app.JumpLoaderApplet.class" archive="/odkup-war/applet/messages_sk.zip, /odkup-war/applet/jumploader_z.jar" width="100%" height="500"> <param name="uc_uploadUrl" value="/odkup-war/UHTest.seam?actionName=UPLOAD" /> <param name="uc_resumeCheckUrl" value="/odkup-war/UHTest.seam?actionName=RESUME" /> .....
Notice two important params - uc-uploadUrl and uc-resumeCheckUrl. These params hold values of URL which are called to fire upload/resume.
My snippet of web.xml
<filter> <filter-name>Seam Filter</filter-name> <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class> </filter> <filter-mapping> <filter-name>Seam Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>Seam Multipart Filter</filter-name> <filter-class>org.jboss.seam.web.MultipartFilter</filter-class> </filter> <filter-mapping> <filter-name>Seam Multipart Filter</filter-name> <url-pattern>*.seam</url-pattern> </filter-mapping>
Enabled multipart filter.
My snippet of components.xml
<web:multipart-filter create-temp-files="true" max-request-size="1000000" url-pattern="*.seam" />
Enabled multipart filter with create-temp-files set to true.
UHTest.xhtml is empty file only with composition tag, here is snippet of UHTest.page.xml
<?xml version="1.0" encoding="UTF-8"?> <page view-id="/UHTest.xhtml" action="#{Uhtest.someAction()}"> </page>
When UHTest is fired from jumploader applet, action Uhtest.someAction() is called to handle multipart form request
My snippet of UHTest.java
@Name("Uhtest") @Scope(ScopeType.SESSION) public class UHTest { ..... public void someAction(){ FacesContext ctx = FacesContext.getCurrentInstance(); org.jboss.seam.web.MultipartRequest request = (org.jboss.seam.web.MultipartRequest)ctx.getExternalContext().getRequest(); //Check parameters inside of request - should be 7, but list is empty Enumeration en = request.getParameterNames(); while(en.hasMoreElements()){ Object param = (Object) en.nextElement(); System.out.println(param+" - "+request.getParameter(param.toString())); } //Calling file param - returns --- BINARY DATA --- System.out.println(request.getParameter("file")); //Returns NULL :o( request.getFileBytes("file"); }
Result is following:
1. File(s) are uploaded correctly to temporary folder ! It's name is something like 1234-5678.upload.
2. When I cast request to MultipartRequest there is no exception.
Problems:
1. I cannot receive list of parameters inserted to multi-part form by applet.
2. The most important thing - I cannot recieve bytes of uploaded file !!
What is wrong ?
Is such a approach correct ? I'm not really sure about UHTest.page.xml approach to call java method ...
Thank you for your reply.