ICEfaces
  1. ICEfaces
  2. ICE-4397

JavaScript errors when using submitOnUpload

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8
    • Fix Version/s: 1.8.3, 1.8.2-EE-GA_P02
    • Component/s: None
    • Labels:
      None
    • Environment:
      JBoss AS 5.0.1.GA, IE7, FF3

      Description

      Client-side JavaScript code which handles submitOnUpload=preUpload, submitOnUpload=postUpload and submitOnUpload=preAndPostUpload is not reliable.

      In particular, it assumes that IFRAME content is loaded within 300 ms which cannot be guaranteed in a networked environment.

      If IFRAME is not loaded fast enough, both IE7 and FF3 display a JavaScript error:

      frame.document.getElementsByTagName("form")[0] is undefined

      After such error happens, submitOnUpload feature ceases to work until page is refreshed.

      Possibly related JIRA issues and forum posts are:
      ICE-3144
      ICE-4246
      http://www.icefaces.org/JForum/posts/list/12180.page

        Activity

        Hide
        User Ryagin added a comment -

        Attached sample application installs a servlet filter which delays rendering of IFRAME content by 3 seconds.

        To test:

        • drop inputFile-submitOnUpload-bug in samples folder
        • run ant
        • deploy
        Show
        User Ryagin added a comment - Attached sample application installs a servlet filter which delays rendering of IFRAME content by 3 seconds. To test: drop inputFile-submitOnUpload-bug in samples folder run ant deploy
        Hide
        User Ryagin added a comment -

        Attached patch moves JavaScript code responsible for handling submitOnUpload feature from main page into IFRAME

        Smelly setTimeout(...) workarounds are not longer necessary with this approach.

        Tested with IE6, IE7, FF3

        Show
        User Ryagin added a comment - Attached patch moves JavaScript code responsible for handling submitOnUpload feature from main page into IFRAME Smelly setTimeout(...) workarounds are not longer necessary with this approach. Tested with IE6, IE7, FF3
        Hide
        Alexander Wallace added a comment -

        This exact same issue is present in 1.7.2-SP2.

        I am going to try the patch on 1.7.2-SP2. It may need backporting. We'll see.

        One thing that concerns me is that this issue is not marked with a Fix Version/s ... Is this issue also present in 1.8.2 ?

        Thanks a lot!

        Show
        Alexander Wallace added a comment - This exact same issue is present in 1.7.2-SP2. I am going to try the patch on 1.7.2-SP2. It may need backporting. We'll see. One thing that concerns me is that this issue is not marked with a Fix Version/s ... Is this issue also present in 1.8.2 ? Thanks a lot!
        Hide
        Alexander Wallace added a comment -

        Ryagin: Could you comment if you have your fix running in production ? And your level of confidence on it?

        Thanks!

        Show
        Alexander Wallace added a comment - Ryagin: Could you comment if you have your fix running in production ? And your level of confidence on it? Thanks!
        Hide
        Alexander Wallace added a comment -

        For 1.7.2-SP2, instead backporting your patch, we fixed it with the following in InputFileRenderer.java:

        103c111,116
        < "var frame = document.getElementById('" + frameName + "').contentWindow;" +

        > "var frameElem = document.getElementById('" + frameName + "');" +
        > "if (!frameElem)

        { setTimeout(register, 100); return; } " + // wait until the frame is found
        > "var frame = frameElem.contentWindow;" +
        > "if (!frame) { setTimeout(register, 100); return; }

        " + // wait until the frame is available;
        > "var formContainer = frame.document.getElementsByTagName('form'); " + // make sure the form to upgrade progres exists, otherwise wait!
        > "if (!formContainer || !formContainer[0])

        { setTimeout(register, 100); return; }

        " +

        perhaps an exageration.. it is basically waiting recursively until the element needed is present.

        We used the provided (thank you very much) filter to force the error, and once this code was applied, the component works as expected.

        For our purposes we added this code to a custom renderer and overrode the default in faces-config.xml

        Hope it helps somebody... Thanks Ryagin for the filter!

        Show
        Alexander Wallace added a comment - For 1.7.2-SP2, instead backporting your patch, we fixed it with the following in InputFileRenderer.java: 103c111,116 < "var frame = document.getElementById('" + frameName + "').contentWindow;" + — > "var frameElem = document.getElementById('" + frameName + "');" + > "if (!frameElem) { setTimeout(register, 100); return; } " + // wait until the frame is found > "var frame = frameElem.contentWindow;" + > "if (!frame) { setTimeout(register, 100); return; } " + // wait until the frame is available; > "var formContainer = frame.document.getElementsByTagName('form'); " + // make sure the form to upgrade progres exists, otherwise wait! > "if (!formContainer || !formContainer [0] ) { setTimeout(register, 100); return; } " + perhaps an exageration.. it is basically waiting recursively until the element needed is present. We used the provided (thank you very much) filter to force the error, and once this code was applied, the component works as expected. For our purposes we added this code to a custom renderer and overrode the default in faces-config.xml Hope it helps somebody... Thanks Ryagin for the filter!
        Hide
        Sergey Petrov added a comment -

        This exact problem still persists in 1.8.2.

        Show
        Sergey Petrov added a comment - This exact problem still persists in 1.8.2.
        Hide
        Mark Collette added a comment -

        Evaluated the suggested patch. Tested scenarios before and after applying the patch.

        Discovered an issue with autoUpload="true" and submitOnUpload="pre[AndPost]Upload". Researched that, and found ICE-5600, which deals with that issue. Solved ICE-5600, and tested that in the context of this jira's fix.

        Subversion 23044

        Show
        Mark Collette added a comment - Evaluated the suggested patch. Tested scenarios before and after applying the patch. Discovered an issue with autoUpload="true" and submitOnUpload="pre [AndPost] Upload". Researched that, and found ICE-5600 , which deals with that issue. Solved ICE-5600 , and tested that in the context of this jira's fix. Subversion 23044

          People

          • Assignee:
            Mark Collette
            Reporter:
            User Ryagin
          • Votes:
            8 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: