1 Reply Latest reply on Nov 12, 2012 12:30 PM by gebuh

    Seam Upload File question

    beastofbobmin

      HI

      I am new to all this(Java included)

      I have used seamgen to create my project which consist of an entity with an id(autogen),name,surname.

      The Crud interface works a treat.

      I wanted to customize it further and

      I have created a new XHTML file which basically at the moment holds a file upload richfaces component and the datatable component to display the contents of the ejb

      I used this example http://www.seamframework.org/Documentation/HowToUploadAndDownloadFilesInSeam. and it works brilliantly.

      The only issue i have now is

      I want to be able to use the file that has just been uploaded to populate the ejb i have created.

      i dont think this is relevent but i want to be able to load txt, csv or xls files. (im happy to write the code that iterates though the excell cell values or the csv values)

      I would like to do this as soon as the file is uploaded by the user.

      Thanks

      beastofbobmin

        • 1. Re: Seam Upload File question
          gebuh

          I do something similar with excel files.  I use the apache poi(http://poi.apache.org/) api to extract data from the uploaded document.  It works for excel and csv, not sure about txt, but I imagine that shouldn't be a problem.

          I get the data from the attachement and convert it to a ByteArrayInputStream, use that to create a Workbook, get a sheet from it and then parse the data from the sheet into a list of objects.

          This was my first attempt at it, so ymmv, but let me know if you need more detail.