11 Replies Latest reply on Feb 17, 2007 5:35 PM by hade79

    Partial steps to get file upload running, final step doesn't

    davidsan1001

      This all follows from Ronalds link below. I spent the day taking the ball and running with it from there and this is what I discovered. I'm not quite home yet, file doesn't seem to actually upload but I think I'm close. Have at it I'll add more when I figure out the final solution.

      http://myfaces.apache.org/tomahawk/fileUpload.html


      1. You need to following files:

      tomahawk.jar
      commons-fileupload-1.0.jar
      fileupload.jsp
      FileUploadForm.java

      (at the bottom are some links to help you find the above)

      2. I recommend putting the jars in the jbpm.3/lib/commmons directory

      3. Modify the build.deploy.xml at about line 112 so those files find their way into the WEB-INF directory

      4. Put the FileUploadForm.java with the Beans at jbpm.3/src/java.webapp/jbpm.war/org/jbpm/webapp/bean

      5. Edit the package name at the top of the file to:
      org.jbpm.webapp.bean


      6. Put the "fileupload.jsp" with the other jsps (jbpm.3/src/resources/java.webapp/

      7. Modify the faces-config.xml

      <!-- Managed Beans for fileupload.jsp -->

      <managed-bean>
      <managed-bean-name>fileUploadForm</managed-bean-name>
      <managed-bean-class>org.jbpm.webapp.bean.FileUploadForm</managed-bean-class>
      <managed-bean-scope>request</managed-bean-scope>
      </managed-bean>

      <!-- Navigation rule for fileupload.jsp -->

      <navigation-rule>
      <from-view-id>/home.jsp</from-view-id>
      <navigation-case>
      <from-outcome>upload_download</from-outcome>
      <to-view-id>/fileupload.jsp</to-view-id>
      </navigation-case>
      </navigation-rule>

      8. Add the following to the home.jsp to give it a button that takes you to the upload/download page

      <h4>Upload or download a file</h4>
      <h:form id="upload">
      <h:commandButton action="upload_download" value="Upload/Download Page"/>

      Here are the links I promised to the files above....

      http://myfaces.apache.org/binary.cgi
      download...
      myfaces-1.1.0.zip (or .tar.gz)
      ..to get..
      /myfaces-1.1.0/tomahawk.jar


      http://jakarta.apache.org/site/downloads/downloads_commons-fileupload.cgi
      ..to get..
      commons-fileupload-1.0.jar


      http://myfaces.apache.org/source.cgi
      ..to get..
      /myfaces-1.1.0-src/webapps/examples
      fileupload.jsp

      same as above..to get..
      /myfaces-1.1.0-src/webapps/src/example/org/apache/myfaces/examples/misc/FileUploadForm.java

        • 1. Re: Partial steps to get file upload running, final step doe
          davidsan1001

          One more step... enable mulitpart filter. Add this to your web.xml


          <filter-name>multipartFilter</filter-name>
          <filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>


          <filter-mapping>
          <filter-name>multipartFilter</filter-name>
          <url-pattern>/*</url-pattern>
          </filter-mapping>

          • 2. Re: Partial steps to get file upload running, final step doe
            davidsan1001

            Stuck here though. "fileupload.jsp" loads fine. Selecting file works fine. Give it a name and hitting the button "load it up" works without any errors, however that file is supposed to show up on the page but doesn't.

            Also, if you hit either of the other two links called "Download Image" I get this error message.
            ----------------------------------------------------------
            HTTP Status 404 - /jbpm/fileupload_showimg.jsf

            type Status report

            message /jbpm/fileupload_showimg.jsf

            description The requested resource (/jbpm/fileupload_showimg.jsf) is not available.
            --------------------------------------------------------------------
            I realize this might be more of a Myfaces issues so I will move over to that group to get help.

            Anyone do this? Anyone know what might be causing this?

            • 3. Re: Partial steps to get file upload running, final step doe
              davidsan1001

              Works! (Not sure where on the filesystem its going yet but, who cares right now!)

              I had to edit the file "fileupload.jsp" and replace
              fileupload_showimg.jsf ... with
              fileupload_showimg.jsp

              Also, I had to copy the fileupload_showimg.jsp into the jbpm.3/src/resources/java.webapp directory..same place as the fileupload.jsp.

              • 4. Re: Partial steps to get file upload running, final step doe
                koen.aers

                This is interesting. Couldn't we use something like this to deploy *.par archive files? The deploy *.par screen would essentially upload the file to the deployment servlet...
                Or did I miss something and was this already the purpose of your trials? ;-)

                Regards,
                Koen

                • 5. Re: Partial steps to get file upload running, final step doe
                  davidsan1001

                  If your question was to me, I'm just interested in uploading a file from a task. Hoping to eventually solve the following use cases.

                  1) Workflow centers around a document, one person starts the workflow uploads a document, next actor on the next task can download the file, make changes, upload. etc etc throughout the workflow.
                  2) Uploaded file is excel spreadsheet. User uploads properly formatted excel sheet (perhaps as xml) this is parsed into a form that can be put into the database.
                  3) Info in the database can be queried and placed into a file then the file is formatted in such a way that the user can open in excel. Lots business folks love their excel and can play with graphs etc.

                  Dave

                  • 6. Re: Partial steps to get file upload running, final step doe
                    davidsan1001

                    So my next step I think is to create a Backing Bean that can take the file and either save it to the file system or into the database.

                    Any help?

                    Dave

                    • 7. Re: Partial steps to get file upload running, final step doe
                      kukeltje

                      Or into a jsr-170 compliant repository. Would be even nicer!!

                      And Koen... Yes, it can be used to deploy par files.

                      • 8. Re: Partial steps to get file upload running, final step doe
                        davidsan1001

                        I'm going there.

                        ..So I found a test case ByteArrayDBTest.java. That has some clues, especially a line

                        ByteArray byteArray = new ByteArray(bytes);
                        jbpmSession.getSession().save(byteArray);

                        seems simple enough to save the file once I get it in a byte array. Now I just have to make the byte array a variable value, give that variable a string name.

                        ..more for tomorrow. Lets see, I have to create a backing bean to capture the graphic file then write some code to convert the graphic file to a byte array, save the byte array as a variable value and name.

                        • 9. Re: Partial steps to get file upload running, final step doe
                          kukeltje

                          David,

                          I would NOT put the file in the jBPM Database. It is not designed for that. Put it in an external DB and just store the referece in thejBPM DB.

                          • 10. Re: Partial steps to get file upload running, final step doe
                            davidsan1001

                            Thanks Ronald. I thought of that after I posted. I found some code for placing the file in the file system. I'll work that out and post again.

                            Dave

                            • 11. Re: Partial steps to get file upload running, final step doe
                              hade79

                              Hi,

                              I have the same problem. I stored a file into the file system of the server. But how do I get the file from the server. I tried to get it by using a link with file.getAbsolutePath() but that doesn't work.

                              Dennis