[jbossseam-issues] [JBoss JIRA] Updated: (JBSEAM-947) Problem with seam component <s:fileUpload/> in JBoss Portal

Chunyun Zhao (JIRA) jira-events at lists.jboss.org
Sat Mar 24 04:54:00 EDT 2007

     [ http://jira.jboss.com/jira/browse/JBSEAM-947?page=all ]

Chunyun Zhao updated JBSEAM-947:

    Attachment: JBSEAM-947.zip

I made a temporary fix to this issue and would like to share it. Hopefully this will help people who are waiting for the fix and also give some hints on the official fix from Seam team.

My fix leverages Apache Portals Portlet Filter library (http://portals.apache.org/bridges/multiproject/portals-bridges-portletfilter/index.html) as well as commons fileupload library. 

All the following changes are made in org.jboss.seam.web package:

1. Renamed existing MultipartRequest class to MultipartServletRequest.
2. Created a new interface MultipartRequest, which is then implemented by both MultipartServletRequest and MultipartPortletRequest.
3. Renamed existing MultipartFilter to MultipartServletFilter, and also changed it to use MultipartServletRequest.
4. Created MultipartPortletRequest that wraps PortletRequest for multipart content. This class also implements MultipartRequest interface, so that it could be used by UIFileUpload component to get the uploaded file(s).
5. Created MultipartPortFilter which implements PortletFilter interface provided by Apache Portlet Filter library. 

org.jboss.seam.ui.UIFileUpload stays the same, but needs to be recompiled with above changes. All the new/modifed code are attached.

The basic work flow:

1. Client sends porlet request with multipart/form-data content type.
2. MultipartPortletFilter intercepts the request, and wraps the portlet request in a MultipartPortletRequest object.
3. The MultipartPortletRequest object is passed to UIFileUpload, which then uses its MultipartRequest interface to access related uploaded file and bind it to the backing bean.
4. MutlipartPortletFilter removes the temporary uploaded files on the disk at the end of the request, as in my case the uploaded documents may contain sensitive data.

New dependencies:


To apply the fix:

1. Compile the attached source code, and update seam jars accordingly.
2. Add new dependencies to WEB-INF\lib.
3. Change your portlet.xml to use Apache FilterPortlet, part of my portlet.xml:




> Problem with seam component <s:fileUpload/> in JBoss Portal
> -----------------------------------------------------------
>                 Key: JBSEAM-947
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-947
>             Project: JBoss Seam
>          Issue Type: Bug
>          Components: JSF
>    Affects Versions: 1.1.5.GA, 1.1.6.GA
>         Environment: Windows XP Pro service pack 2, I.E. and FireFox, JBossAS 4.0.5.GA, JBoss Portal 2.4.1
>            Reporter: Pietro Passantini
>         Assigned To: Shane Bryzak
>         Attachments: JBSEAM-947.zip
> I need to upload a file to Jackrabbit Repository using Seam Framework running on Portlet, with the <s:fileUpload/> component.
> It doesn't work.
> I've tried different ways to solve the problem, but none worked.
> It could be a bug.
> It seams that when the enctype of h:form is ="multipart/form-data", the method upload of fileManager is not called; if I don't set the enctype of h:form the method upload is called, but the bean file is null.
> I'm trying with this configutaration:
> <h:form id="myForm" enctype="multipart/form-data" >
> <s:fileUpload accept="" fileName="#{file.filename}" data="#{file.data}" />
> <h:commandButton value="Upload" action="#{fileManager.upload}"/>
> </h:form>
> "file" is the bean that represents the file uploaded
> "fileManager" is the bean that use the file uploaded
> ...
> <filter-name>Seam Filter</filter-name>
> <filter-class>org.jboss.seam.servlet.SeamMultipartFilter</filter-class>
> <filter-mapping>
> <filter-name>Seam Filter</filter-name>
> <url-pattern>*.seam</url-pattern>
> </filter-mapping>
> ...

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the seam-issues mailing list