[jboss-user] [JBoss Seam] - Re: Simplest <s:fileUpload> usage

landrew do-not-reply at jboss.com
Wed May 23 14:59:57 EDT 2007


This solution of reading uploaded file thru byte[] works.  Thank you for sharing.

However, I wanted to use a different approach using Backing Bean wrapping org.apache.myfaces.custom.fileupload.UploadedFile component.

In my attempt as stated, I found that the Backing Bean was instantiated ok, the file upload Browse and Submit buttons were generated ok but when Submit is clicked, the JSF failed to inject the multipart UploadedFile to it, so the Action listener class received Backing Bean with a null UploadedFile object.
The Backing Bean is a Seam component but the UploadedFile is JSF multipart/form-data component.

I would appreciate any help shed some light in this.
Thanks - landrew.

Code snippets as shown:

fileUpload.xhtml:
..
        <h:form enctype="multipart/form-data" >
          
	          Browse and Pick a File
              <t:inputFileUpload value="#{uploadBean.uploadedFile}" storage="file" />
              <h:commandButton value="Submit" action="#{uploader.upload}" />
              
        </h:form>
..

UploadBean.java (Backing Bean)
..
@Name("uploadBean")
@Scope(SESSION)
public class UploadBean
{    
    @In(required=false)
    private UploadedFile uploadedFile;
..

UploadAction.java (Action class JSF Listener)
..
@Name("uploader")
@Scope(EVENT)
public class UploadAction implements UploadActionIF
{
    private final String CLAZZ = this.getClass().toString();

    /**
     * Uploaded file wrapper object.
     */
    @In(required = false)
    private UploadBean uploadBean;
..
    public String upload()
    {
..

Other components:
- jboss-4.0.5.GA Server
- WEB-INF/tomahawk.taglib.xml
- tomahawk-1.1.5.jar
- jboss-seam.jar thru Seam-Version: 1.2.0.PATCH1
- jsf-facelets.jar Implementation-Version: 1.1.12



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048021#4048021

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048021



More information about the jboss-user mailing list