ICEfaces-EE
  1. ICEfaces-EE
  2. IPCK-472

InputFile: JS error occuring in File Upload Demo

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: EE-1.8.2.GA_P05
    • Fix Version/s: EE-1.8.2.GA_P08
    • Component/s: Facelet Components
    • Labels:
      None
    • Environment:
      ICEfaces EE 1.8.2.GA_P07 Build7
      IE9/10
    • Assignee Priority:
      P1

      Description

      Process Components > File Upload Progress
      JS error occurs when navigating to this demo and then navigating away from it. Only reproducible in IE9/10:
      Message: Unable to set property 'InputFileIdPostUpload' of undefined or null reference
      Line: 1
      Char: 76
      Code: 0
      URI: http://ec2-54-212-81-211.us-west-2.compute.amazonaws.com:7001/icefaces-enterprise-comps-showcase/uploadHtml

        Activity

        Hide
        Philip Breau added a comment -

        js error under same conditions is also occurring in the ICEfaces 1.8 Showcase:

        <script type="text/javascript">
        var submit = function() { 
           if(arguments.length == 1 && arguments[0] == 1) { 
              parent.Ice.InputFileIdPostUpload = 'iceform:icepnltabset:0:myInputFile_inputFile'; 
              parent.Ice.InputFileIdPreUpload = null; 
           } 
           else { return; } 
           try { 
              if(parent.document.getElementById('iceform')) { 
                 parent.document.getElementById('iceform').submit(); 
              } 
           } catch (e) { parent.logger.warn('Form not available', e); } 
           finally { 
              parent.Ice.InputFileIdPreUpload = null; 
              parent.Ice.InputFileIdPostUpload = null; 
           } 
        };
        document.getElementsByTagName('form')[0].onsubmit = submit;
        var uploadEnd = function() { submit(1);};
        if (window.attachEvent) { 
           window.attachEvent('onunload', uploadEnd); 
        } else { 
           window.onunload = uploadEnd; 
        }
        </script>
        

        'parent.Ice' on the first reference of InputFileIdPostUpload is undefined. Looks like the script from the file upload iframe is running on a navigation and the reference to parent.Ice has already been unloaded.

        Show
        Philip Breau added a comment - js error under same conditions is also occurring in the ICEfaces 1.8 Showcase: <script type= "text/javascript" > var submit = function() { if (arguments.length == 1 && arguments[0] == 1) { parent.Ice.InputFileIdPostUpload = 'iceform:icepnltabset:0:myInputFile_inputFile'; parent.Ice.InputFileIdPreUpload = null ; } else { return ; } try { if (parent.document.getElementById('iceform')) { parent.document.getElementById('iceform').submit(); } } catch (e) { parent.logger.warn('Form not available', e); } finally { parent.Ice.InputFileIdPreUpload = null ; parent.Ice.InputFileIdPostUpload = null ; } }; document.getElementsByTagName('form')[0].onsubmit = submit; var uploadEnd = function() { submit(1);}; if (window.attachEvent) { window.attachEvent('onunload', uploadEnd); } else { window.onunload = uploadEnd; } </script> 'parent.Ice' on the first reference of InputFileIdPostUpload is undefined. Looks like the script from the file upload iframe is running on a navigation and the reference to parent.Ice has already been unloaded.
        Hide
        Mark Collette added a comment - - edited

        What are the DOM updates coming back to the browser for the:

        • Pre-upload
        • File upload
        • Post-upload
        Show
        Mark Collette added a comment - - edited What are the DOM updates coming back to the browser for the: Pre-upload File upload Post-upload
        Hide
        Mark Collette added a comment -

        And where does that script come from, that Philip posted?

        Show
        Mark Collette added a comment - And where does that script come from, that Philip posted?
        Hide
        Philip Breau added a comment - - edited

        It's rendered by the Input File component. InputFile.java

        Show
        Philip Breau added a comment - - edited It's rendered by the Input File component. InputFile.java
        Hide
        Mark Collette added a comment -

        It makes sense now, the ice:inputFile has postUpload set to true and preUpload set to false, and this is the script that gets rendered. So all I need is the DOM updates that come back in the upload, to see if that's nuking the iframe, and thus ruining the postUpload environment.

        Show
        Mark Collette added a comment - It makes sense now, the ice:inputFile has postUpload set to true and preUpload set to false, and this is the script that gets rendered. So all I need is the DOM updates that come back in the upload, to see if that's nuking the iframe, and thus ruining the postUpload environment.
        Hide
        Mark Collette added a comment -

        I'm investigating using onbeforeunload instead of onunload, or using a setTimeout in the postUpload handling, in case the parent is temporarily unavailable.

        Seems related:
        http://social.msdn.microsoft.com/Forums/ie/en-US/00b88378-a7f1-4148-9587-1ff17d6fa728/windows-7-problem-with-submit-in-onbeforeunload-event-in-ie

        Show
        Mark Collette added a comment - I'm investigating using onbeforeunload instead of onunload, or using a setTimeout in the postUpload handling, in case the parent is temporarily unavailable. Seems related: http://social.msdn.microsoft.com/Forums/ie/en-US/00b88378-a7f1-4148-9587-1ff17d6fa728/windows-7-problem-with-submit-in-onbeforeunload-event-in-ie
        Hide
        Mircea Toma added a comment -

        The fix applied modifies the iframes included in the element that is about to be updated to force the browser into honouring the 'beforeunload' and 'unload' events. Modified InputFile iframe to use 'beforeunload' event so that the elements it works with are still available.

        Show
        Mircea Toma added a comment - The fix applied modifies the iframes included in the element that is about to be updated to force the browser into honouring the 'beforeunload' and 'unload' events. Modified InputFile iframe to use 'beforeunload' event so that the elements it works with are still available.

          People

          • Assignee:
            Mircea Toma
            Reporter:
            Cruz Miraback
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: