2 Replies Latest reply on Apr 13, 2007 4:05 AM by larseirik

    help on s:fileUpload

    kingcu

      Seam version 1.2.1.

      I am always getting NULL value for the upload file. I tried using both InputStream and byte[]; I also tried putting the upload file property in a SLSB and a class that extends EntityHome, but neither worked. Anyway here is my code:

       <h:form enctype="multipart/form-data">
       <rich:togglePanel id="importFeeds" switchType="ajax" stateOrder="closed, import">
       <f:facet name="closed">
       <h:panelGrid columns="1">
       <rich:toggleControl for="importFeeds" value="Import Feeds &#187;" />
       </h:panelGrid>
       </f:facet>
       <f:facet name="import">
       <h:panelGrid columns="1">
       <s:fileUpload data="#{widgetHome.feedDefFile}" />
       <s:button id="importFeed" value="Import..." action="#{widgetHome.importFeeds}"/>
       <rich:toggleControl for="importFeeds" value="&#171; Close Import" />
       </h:panelGrid>
       </f:facet>
       </rich:togglePanel>
       </h:form>
      


      @Name("widgetHome")
      public class WidgetHome extends EntityHome<Widget> {
      
       .... // other methods
      
      
       @Logger
       private Log log;
      
       // No matter whether it's byte[] or InputStream, it's always null
       private byte[] feedDefFile;
       //private InputStream feedDefFile;
      
       public void importFeeds() {
       // I get an NPE exception on this, because feedDefFile is always null
       log.info("feedDefFile.length = " + feedDefFile.length);
       }
      
      }
      


        • 1. Re: help on s:fileUpload
          kingcu

          Just realized that s:button doesn't submit a form, so changed it to h:commandButton and it worked.

          • 2. Re: help on s:fileUpload
            larseirik

            Hi. I have tried to get the <s:fileUpload> going myself, but it seems i am not able to bind it to my field. Whenever i try to access my fileData binding it returns null as a value.

            I am using a sessionbean, but apart from that i do what you do.
            Any help is greatly appreciated