3 Replies Latest reply on Jul 8, 2013 6:34 PM by Brian Leathem

    FileUpload init

    Fernando Martins Newbie

      I use richfaces 4.3.2 final version in JBOSS 7.1

       

      I need to initialize the FileUpload object with data stored in a database

       

      I used the DATA attribute but it doesn't work :

       

      --------------

      view

      ---------------

       

      <rich:fileUpload id="upload"

                           immediateUpload="false"

                           data="#{upload.files}"

                           addLabel="#{msgs.addLabel}"

                           clearAllLabel="#{msgs.clearAllLabel}"

                           clearLabel="#{msgs.clearLabel}"

                           serverErrorLabel="#{msgs.serverErrorLabel}"

                           deleteLabel="#{msgs.deleteLabel}"

                           doneLabel="#{msgs.doneLabel}"

                           sizeExceededLabel="#{msgs.sizeExceededLabel}"

                           uploadLabel="#{msgs.uploadLabel}"

                           fileUploadListener="#{upload.listener}">

              <a4j:ajax event="uploadcomplete" execute="@none" render="info"/>

          </rich:fileUpload>

       

      -------------------------------

      my bean :

      --------------------------------

       

       

      private ArrayList<Uploads> files;

       

      the Uploads class does have NAME and DATA attributes

       

        public void setFiles(ArrayList<Uploads> files) {

              this.files = files;

          }

       

          public ArrayList<Uploads> getFiles() throws ErroNegocio {

       

              /* LOAD DATA FROM DATABASE */

              ContextoAplicacional ctx = getContextoAplicacional();

            

             

              if (files == null) {

                  files = new ArrayList<Uploads>();

                  files = Locator.getGereGeral(ctx).consultarTodos(ctx,getInfo().getOpeNumDoc(),getInfo().getOpeVerDoc());

              }

             

            /* END READING FROM DATABASE */

       

              return files;

          }

       

       

      thanks in advance

        • 1. Re: FileUpload init
          Brian Leathem Master

          From the vdl doc (http://docs.jboss.org/richfaces/latest_4_X/vdldoc/rich/fileUpload.html), the data attribute is described as:

           

          Serialized (on default with JSON) data passed to the client by a developer on an AJAX request. It's accessible via "event.data" syntax. Both primitive types and complex types such as arrays and collections can be serialized and used with data

           

          The use case you are describing does not sound like a good fit with that description.

           

          You might be able to achieve what you are looking for with some javascript that retrieves the data from a hidden element and interacts sets the fileupload javascript to initialize it's state.

           

          Additionally you can file a jira issue asking for such functionality to be added via a server-side API, but that won't solve your immediate concerns.

          • 2. Re: FileUpload init
            Fernando Martins Newbie

            You said :

             

            "You might be able to achieve what you are looking for with some javascript that retrieves the data from a hidden element and interacts sets the fileupload javascript to initialize it's state."

             

            how can I do that ?!  can give me some example ? just for populate with file names

             

             

            "Additionally you can file a jira issue asking for such functionality to be added via a server-side API, but that won't solve your immediate concerns."

             

            would be a great improvement for this rich component if it can be initialized just like a DataTable "value" attribute. I saw in google another person with the same need without any answer

             

            Where can I make that request ?

             

            thank you very much

            • 3. Re: FileUpload init
              Brian Leathem Master

              I'll see if I can find some time to put together an example demonstrating what you are talking about.

               

              Instructions on filing effective issue reports can be found in our wiki:

              https://community.jboss.org/wiki/SubmittingEffectiveIssueReports