4 Replies Latest reply on Apr 30, 2010 8:31 AM by hesher

    FileUpload does not refresh the page/component on fileuploadcomplete.

    hesher

      Hi,

       

      A screenshot of the webpage before I explain the problem:

      http://farm5.static.flickr.com/4022/4563297064_3c2dd50ff7_o.png

      The fileUpload component in the right upper corner loads a file and then alters the left panel by adding a few rows (like the three already shown).

      The rows are HTMLPanelGrid objects.

      The new rows are added from the fileuploadeventlistener functions.

       

      If I refresh the page manually after the rows were added they are visible, but nothing happens if I don't refresh automatically.

      I tried to use the a4j:support with onfileuploadcomplete and reRendering the PanelGrid which is the left panel that holds the rows.

      Also tried to reRender the new rows themeselves.

       

      Nothing seems to work. It doesn't refresh..

      It seems that only the fileupload component doesn't refresh, the other buttons work great.

      Just incase anyone want's to check out the implementation (Reduced...):

       

      @SuppressWarnings("deprecation")
      private void addRichFileUpload(UIComponent grid) {
      HtmlFileUpload upload = new HtmlFileUpload();
      upload.setAddControlLabel("Load Script");
       
      upload.setFileUploadListener(FacesContext
      .getCurrentInstance().getApplication().createMethodBinding(
      "#{actions.uploadScriptEventListener}",
      new Class[] { UploadEvent.class }));
      updateComponentOnUploadComplete(upload, "LeftColumn, newbutton1, newbutton2"); 
      grid.getChildren().add(upload);
      }
       
      public void uploadScriptEventListener(UploadEvent uploadEvent) throws ScriptManagerException {
      
      System.out.println("Script Upload Complete");
       
      // Add New Rows To Left Column....
      }
      
      public static void updateComponentOnUploadComplete(
                UIComponent componentToListenTo, String componentToReRenderID) {
           HtmlAjaxSupport support = new HtmlAjaxSupport();
           support.setReRender(componentToReRenderID);
           support.setEvent("onuploadcomplete");
           componentToListenTo.getChildren().add(support);
      }
      

       

      Any suggestions?

       

      Thanks!