ICEfaces
  1. ICEfaces
  2. ICE-9338

Resource coalescing omitting fileentry.js

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.3, EE-3.3.0.GA
    • Fix Version/s: EE-3.3.0.GA_P01, 4.0.BETA, 4.0
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      Liferay portal 6.1.1 on Tomcat 7.0.27 with Liferay faces bridge 3.1.2 and ICEfaces 3.3 EE tag branch HEAD
    • Assignee Priority:
      P1

      Description

      Having an ICEfaces ACE FileEntry portlet on its own works fine with coalescing. The included fileentry.js code can be readily found. But, if another ACE component sample portlet is added, for example Accordion, and the display is refreshed, then there is this exception:

      Uncaught TypeError: Cannot call method 'captureFormOnsubmit' of undefined

      This is because the ice.ace.fileentry.captureFormOnsubmit function is not found since the file it comes in is not included:

      icefaces/ace/component/resources/icefaces.ace/fileentry/fileEntry.js

      This might be related to ICE-9263.

        Issue Links

          Activity

          Mark Collette created issue -
          Mark Collette made changes -
          Field Original Value New Value
          Assignee Deryk Sinotte [ deryk.sinotte ]
          Fix Version/s EE-3.3.0.GA [ 10572 ]
          Fix Version/s 3.4 [ 10770 ]
          Assignee Priority P1 [ 10010 ]
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #36173 Tue Jun 11 17:21:05 MDT 2013 deryk.sinotte ICE-9338: adjust coalescing of scripts to use "safe" session attribute access so that it works in portlets as well
          Files Changed
          Commit graph MODIFY /icefaces3/trunk/icefaces/core/src/main/java/org/icefaces/impl/application/CoalescingResourceHandler.java
          Hide
          Deryk Sinotte added a comment - - edited

          Fixed most of the outstanding issues with portlets by modifying the CoalescingResourceHandler to use the proper session scope for portlets.

          There is still an outstanding problem with the Context Menu example in that they fail when included on the same page with the File Entry example. The Context Menu examples work fine in any of the following scenarios:

          • they are on a page by themselves
          • they are on a page with other portlets (except File Entry)
          • coalescing is turned off

          So it's very specific to the combination of Context Menu + File Entry + coalescing together.

          Show
          Deryk Sinotte added a comment - - edited Fixed most of the outstanding issues with portlets by modifying the CoalescingResourceHandler to use the proper session scope for portlets. There is still an outstanding problem with the Context Menu example in that they fail when included on the same page with the File Entry example. The Context Menu examples work fine in any of the following scenarios: they are on a page by themselves they are on a page with other portlets (except File Entry) coalescing is turned off So it's very specific to the combination of Context Menu + File Entry + coalescing together.
          Hide
          Deryk Sinotte added a comment -

          On the client side, the following exception occurs when Context Menu + File Entry are on the same page and coalescing is on:

          uncaught exception: Missing resources for "ContextMenu" component. See "http://www.icesoft.org/wiki/display/ICE/mandatoryResourceConfiguration" for more details.

          Show
          Deryk Sinotte added a comment - On the client side, the following exception occurs when Context Menu + File Entry are on the same page and coalescing is on: uncaught exception: Missing resources for "ContextMenu" component. See "http://www.icesoft.org/wiki/display/ICE/mandatoryResourceConfiguration" for more details.
          Hide
          Deryk Sinotte added a comment -

          Just some more data collection...not sure what it implies at this point. I tried a number of combinations of File Entry with one other component on a portal page with the following results:

          Works

          • File Entry + Accordion
          • File Entry + Datatable
          • File Entry + Autocomplete

          Doesn't work (coalescing must be on, when coalescing is off it all works)

          • File Entry + Context Menu
            File Entry works fine but the Context Menu fails:
            uncaught exception: Missing resources for "ContextMenu" component. See "http://www.icesoft.org/wiki/display/ICE/mandatoryResourceConfiguration" for more details.
          • File Entry + Menu
            Menu works fine. File Entry fails the first time you try to use it to upload a file:
            TypeError: ice.ace.fileentry is undefined
            but during the first use the fileentry.js resource is loaded and everything works after that.
          • File Entry + Chart
            File Entry works fine but the Chart fails to render:
            TypeError: ice.ace.jq.jqplot is undefined
          Show
          Deryk Sinotte added a comment - Just some more data collection...not sure what it implies at this point. I tried a number of combinations of File Entry with one other component on a portal page with the following results: Works File Entry + Accordion File Entry + Datatable File Entry + Autocomplete Doesn't work (coalescing must be on, when coalescing is off it all works) File Entry + Context Menu File Entry works fine but the Context Menu fails: uncaught exception: Missing resources for "ContextMenu" component. See "http://www.icesoft.org/wiki/display/ICE/mandatoryResourceConfiguration" for more details. File Entry + Menu Menu works fine. File Entry fails the first time you try to use it to upload a file: TypeError: ice.ace.fileentry is undefined but during the first use the fileentry.js resource is loaded and everything works after that. File Entry + Chart File Entry works fine but the Chart fails to render: TypeError: ice.ace.jq.jqplot is undefined
          Hide
          Deryk Sinotte added a comment -

          The problem seems to be related to how the resource-dependencies for the ACE components are structured and how the CoalescingResourceHandler deals with multiple views being processed for the same page.

          The problem is related to how we process and handle resources during coalescing. Inside the CoalescingResourceHandler there is an inner class called ResourceCollector. It's a SystemEventListener set to listen for a UIViewRoot's PreRenderComponent event. So just before the View is rendered, the ResoureCollector.replaceResources method is called to do the processing on the resources in the head. This involves figuring out what should go into the coalesced.js and coalesced.css files and in what order.

          The problem is that the logic in this method only takes into account the possibility of a single View being processed. In short, with portlets, when two or more views get run through the ResourceCollector the resources of one view can end up removing one or more resources of the second view.

          As an example, let's consider File Entry + Context Menu. When the view for the File Entry portlet is processed, the following script resources are coalesced:

            name: bridge.uncompressed.js           lib: ice.core
            name: icepush.uncompressed.js          lib: ice.push
            name: util/ace-jquery.js               lib: icefaces.ace
            name: compat.uncompressed.js           lib: ice.compat
            name: icefaces-ee.js                   lib: null
            name: util/ace-components.js           lib: icefaces.ace
            name: icefaces-compat.uncompressed.js  lib: ice.compat
            name: util/ace-datatable.js            lib: icefaces.ace
            name: fileentry/fileEntry.js           lib: icefaces.ace
            name: mobi.js                          lib: null
          

          When it processes the view for the Context Menu, the list of coalesced resources is:

            name: bridge.uncompressed.js           lib: ice.core
            name: icepush.uncompressed.js          lib: ice.push
            name: util/ace-jquery.js               lib: icefaces.ace
            name: compat.uncompressed.js           lib: ice.compat
            name: icefaces-ee.js                   lib: null
            name: util/ace-components.js           lib: icefaces.ace
            name: icefaces-compat.uncompressed.js  lib: ice.compat
            name: util/ace-menu.js                 lib: icefaces.ace
            name: util/ace-datatable.js            lib: icefaces.ace
            name: mobi.js                          lib: null
          

          They mostly overlap in that they include the same things. Except one includes fileEntry.js and the other includes ace-menu.js. In this case, if the File Entry portal is processed last, the coalesced.js file will not contain ace-menu.js and the component will fail to function properly.

          The way that the various .js files for ACE are combined and the way that the resource-dependency.xml is configured further complicates the scenario. The .js files are combined into various groupings where code for various components ends up in some "logical" place (e.g. ace-datatable.js or ace-chart.js). Some, like fileentry.js are on their own and others that don't have their own group are just stuck into ace-components.js (e.g. ice.ace.checkboxbutton and ice.ace.Calendar).

          The ACE resource-dependency.xml includes:

              <resource name="util/ace-jquery.js" library="icefaces.ace">
                  <depends-on>
                      <resource name="jquery/ui/jquery-ui.css" library="icefaces.ace"/>
                  </depends-on>
              </resource>
              <resource name="util/ace-components.js" library="icefaces.ace">
                  <depends-on>
                      <resource name="util/ace-yui.js" library="icefaces.ace"/>
                      <resource name="util/ace-jquery.js" library="icefaces.ace"/>
                      <resource name="util/combined.css"  library="icefaces.ace"/>
                      <resource name="bridge.uncompressed.js" library="ice.core"/>
                      <resource name="bridge.js" library="ice.core"/>
                  </depends-on>
              </resource>
              <resource name="autocompleteentry/autocompleteentry.js" library="icefaces.ace">
                  <depends-on>
                      <resource name="util/ace-components.js" library="icefaces.ace"/>
                  </depends-on>
              </resource>
              <resource name="chart/ace-chart.js" library="icefaces.ace">
                  <depends-on>
                      <resource name="util/ace-components.js" library="icefaces.ace"/>
                  </depends-on>
              </resource>
              <resource name="util/ace-menu.js" library="icefaces.ace">
                  <depends-on>
                      <resource name="util/ace-components.js" library="icefaces.ace"/>
                  </depends-on>
              </resource>
              <resource name="util/ace-datatable.js" library="icefaces.ace">
                  <depends-on>
                      <resource name="util/ace-components.js" library="icefaces.ace"/>
                  </depends-on>
              </resource>
              <resource name="fileentry/fileEntry.css" library="icefaces.ace">
                  <depends-on>
                      <resource name="util/combined.css"  library="icefaces.ace"/>
                  </depends-on>
              </resource>
              <resource name="fileentry/fileEntry.js" library="icefaces.ace">
                  <depends-on>
                      <resource name="util/ace-components.js" library="icefaces.ace"/>
                      <resource name="fileentry/fileEntry.css" library="icefaces.ace"/>
                  </depends-on>
              </resource>
          

          As you can see, almost everything depends on ace-components.js so any of the components in that file will be included. But if there is a gap in the dependencies between two views (one contains fileentry.js and once contains ace-menu.js) then only one view will win and the other view will miss their dependencies. The combinations that prove to be a problem are the outliers (fileentry.js, ace-chart.js, etc.). Any combination of portlets that includes a these on the same page runs into this issue.

          What needs to happen is that the ResourceCollector needs to be refactored so that it is sensitive to multiple views impacting a single set of head resources since this is what portlets require when coalesced. Portlets from the same war can share the same session (that fix has already been made) but the logic needs to merge dependencies from multiple views on the same page.

          Show
          Deryk Sinotte added a comment - The problem seems to be related to how the resource-dependencies for the ACE components are structured and how the CoalescingResourceHandler deals with multiple views being processed for the same page. The problem is related to how we process and handle resources during coalescing. Inside the CoalescingResourceHandler there is an inner class called ResourceCollector. It's a SystemEventListener set to listen for a UIViewRoot's PreRenderComponent event. So just before the View is rendered, the ResoureCollector.replaceResources method is called to do the processing on the resources in the head. This involves figuring out what should go into the coalesced.js and coalesced.css files and in what order. The problem is that the logic in this method only takes into account the possibility of a single View being processed. In short, with portlets, when two or more views get run through the ResourceCollector the resources of one view can end up removing one or more resources of the second view. As an example, let's consider File Entry + Context Menu. When the view for the File Entry portlet is processed, the following script resources are coalesced: name: bridge.uncompressed.js lib: ice.core name: icepush.uncompressed.js lib: ice.push name: util/ace-jquery.js lib: icefaces.ace name: compat.uncompressed.js lib: ice.compat name: icefaces-ee.js lib: null name: util/ace-components.js lib: icefaces.ace name: icefaces-compat.uncompressed.js lib: ice.compat name: util/ace-datatable.js lib: icefaces.ace name: fileentry/fileEntry.js lib: icefaces.ace name: mobi.js lib: null When it processes the view for the Context Menu, the list of coalesced resources is: name: bridge.uncompressed.js lib: ice.core name: icepush.uncompressed.js lib: ice.push name: util/ace-jquery.js lib: icefaces.ace name: compat.uncompressed.js lib: ice.compat name: icefaces-ee.js lib: null name: util/ace-components.js lib: icefaces.ace name: icefaces-compat.uncompressed.js lib: ice.compat name: util/ace-menu.js lib: icefaces.ace name: util/ace-datatable.js lib: icefaces.ace name: mobi.js lib: null They mostly overlap in that they include the same things. Except one includes fileEntry.js and the other includes ace-menu.js. In this case, if the File Entry portal is processed last, the coalesced.js file will not contain ace-menu.js and the component will fail to function properly. The way that the various .js files for ACE are combined and the way that the resource-dependency.xml is configured further complicates the scenario. The .js files are combined into various groupings where code for various components ends up in some "logical" place (e.g. ace-datatable.js or ace-chart.js). Some, like fileentry.js are on their own and others that don't have their own group are just stuck into ace-components.js (e.g. ice.ace.checkboxbutton and ice.ace.Calendar). The ACE resource-dependency.xml includes: <resource name= "util/ace-jquery.js" library= "icefaces.ace" > <depends-on> <resource name= "jquery/ui/jquery-ui.css" library= "icefaces.ace" /> </depends-on> </resource> <resource name= "util/ace-components.js" library= "icefaces.ace" > <depends-on> <resource name= "util/ace-yui.js" library= "icefaces.ace" /> <resource name= "util/ace-jquery.js" library= "icefaces.ace" /> <resource name= "util/combined.css" library= "icefaces.ace" /> <resource name= "bridge.uncompressed.js" library= "ice.core" /> <resource name= "bridge.js" library= "ice.core" /> </depends-on> </resource> <resource name= "autocompleteentry/autocompleteentry.js" library= "icefaces.ace" > <depends-on> <resource name= "util/ace-components.js" library= "icefaces.ace" /> </depends-on> </resource> <resource name= "chart/ace-chart.js" library= "icefaces.ace" > <depends-on> <resource name= "util/ace-components.js" library= "icefaces.ace" /> </depends-on> </resource> <resource name= "util/ace-menu.js" library= "icefaces.ace" > <depends-on> <resource name= "util/ace-components.js" library= "icefaces.ace" /> </depends-on> </resource> <resource name= "util/ace-datatable.js" library= "icefaces.ace" > <depends-on> <resource name= "util/ace-components.js" library= "icefaces.ace" /> </depends-on> </resource> <resource name= "fileentry/fileEntry.css" library= "icefaces.ace" > <depends-on> <resource name= "util/combined.css" library= "icefaces.ace" /> </depends-on> </resource> <resource name= "fileentry/fileEntry.js" library= "icefaces.ace" > <depends-on> <resource name= "util/ace-components.js" library= "icefaces.ace" /> <resource name= "fileentry/fileEntry.css" library= "icefaces.ace" /> </depends-on> </resource> As you can see, almost everything depends on ace-components.js so any of the components in that file will be included. But if there is a gap in the dependencies between two views (one contains fileentry.js and once contains ace-menu.js) then only one view will win and the other view will miss their dependencies. The combinations that prove to be a problem are the outliers (fileentry.js, ace-chart.js, etc.). Any combination of portlets that includes a these on the same page runs into this issue. What needs to happen is that the ResourceCollector needs to be refactored so that it is sensitive to multiple views impacting a single set of head resources since this is what portlets require when coalesced. Portlets from the same war can share the same session (that fix has already been made) but the logic needs to merge dependencies from multiple views on the same page.
          Hide
          Deryk Sinotte added a comment -

          Linking to parent case

          Show
          Deryk Sinotte added a comment - Linking to parent case
          Deryk Sinotte made changes -
          Link This issue depends on ICE-9263 [ ICE-9263 ]
          Deryk Sinotte made changes -
          Fix Version/s EE-3.3.0.GA [ 10572 ]
          Deryk Sinotte made changes -
          Affects Version/s 3.3 [ 10370 ]
          Ken Fyten made changes -
          Assignee Deryk Sinotte [ deryk.sinotte ] Mircea Toma [ mircea.toma ]
          Hide
          Mircea Toma added a comment -

          The resources collected previously are merged now with the currently collected ones so that when multiple views are processed (such as in portlets) the coalescing resource contains the resources needed by all the rendered views.

          Show
          Mircea Toma added a comment - The resources collected previously are merged now with the currently collected ones so that when multiple views are processed (such as in portlets) the coalescing resource contains the resources needed by all the rendered views.
          Mircea Toma made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #36967 Tue Jul 16 10:17:36 MDT 2013 mircea.toma ICE-9338 The resources collected previously are merged now with the currently collected ones so that when multiple views are processed (such as in portlets) the coalescing resource contains the resources needed by all the rendered views.
          Files Changed
          Commit graph MODIFY /icefaces3/trunk/icefaces/core/src/main/java/org/icefaces/impl/event/ResourceOrdering.java
          Commit graph MODIFY /icefaces3/trunk/icefaces/core/src/main/java/org/icefaces/impl/application/CoalescingResourceHandler.java
          Ken Fyten made changes -
          Fix Version/s EE-3.3.0.GA_P01 [ 11174 ]
          Ken Fyten made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Ken Fyten made changes -
          Link This issue blocks ICE-9433 [ ICE-9433 ]
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #36976 Tue Jul 16 15:13:34 MDT 2013 mircea.toma ICE-9338, ICE-9433 Make sure to also add the unordered resources at the end of the list of merged resources.
          Files Changed
          Commit graph MODIFY /icefaces3/trunk/icefaces/core/src/main/java/org/icefaces/impl/application/CoalescingResourceHandler.java
          Hide
          Mircea Toma added a comment -

          Backported fix to EE branch.

          Show
          Mircea Toma added a comment - Backported fix to EE branch.
          Mircea Toma made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Hide
          Carmen Cristurean added a comment - - edited

          Showcase tests fail on icefaces3/trunk rev# 36979 or Jenkins Build#1400:
          There is a JS error that starts occurring in Firefox21 when navigating to various demos in showcase:

          TypeError: Ice.DnD is undefined
          http://localhost:8080/showcase/javax.faces.resource/coalesced.js.jsf?ln=ice.core&dgst=r62d0r
          Line 12695

          At the same time, the Firefox browser memory increases continuously and eventually the browser crashes after a while, if continuing running the tests.

          Turning the coalescing off, the errors could not be reproduced any longer.

          Show
          Carmen Cristurean added a comment - - edited Showcase tests fail on icefaces3/trunk rev# 36979 or Jenkins Build#1400: There is a JS error that starts occurring in Firefox21 when navigating to various demos in showcase: TypeError: Ice.DnD is undefined http://localhost:8080/showcase/javax.faces.resource/coalesced.js.jsf?ln=ice.core&dgst=r62d0r Line 12695 At the same time, the Firefox browser memory increases continuously and eventually the browser crashes after a while, if continuing running the tests. Turning the coalescing off, the errors could not be reproduced any longer.
          Carmen Cristurean made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Hide
          Mircea Toma added a comment -

          The browser memory is growing because the coalesced files grow while the application is used.

          Show
          Mircea Toma added a comment - The browser memory is growing because the coalesced files grow while the application is used.
          Hide
          Mircea Toma added a comment -

          Implement hashCode method for the CoalescingResource.Info class to make the hash set used for merging resources is effective when removeAll method is invoked on the set.

          Show
          Mircea Toma added a comment - Implement hashCode method for the CoalescingResource.Info class to make the hash set used for merging resources is effective when removeAll method is invoked on the set.
          Mircea Toma made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #37007 Wed Jul 17 17:17:24 MDT 2013 mircea.toma ICE-9338 Implement hashCode method for the CoalescingResource.Info class to make the hash set used for merging resources effective when removeAll() method is invoked on the set.
          Files Changed
          Commit graph MODIFY /icefaces3/trunk/icefaces/core/src/main/java/org/icefaces/impl/application/CoalescingResource.java
          Hide
          Liana Munroe added a comment -

          Was not able to reproduce in FF 21, IE 9, or Chrome 28 in trunk, revision #37037.

          Show
          Liana Munroe added a comment - Was not able to reproduce in FF 21, IE 9, or Chrome 28 in trunk, revision #37037.
          Ken Fyten made changes -
          Summary Resource coalescing omitting fileentry.js in portlets Resource coalescing omitting fileentry.js
          Ken Fyten made changes -
          Fix Version/s 4.0 [ 11382 ]
          Ken Fyten made changes -
          Status Resolved [ 5 ] Closed [ 6 ]

            People

            • Assignee:
              Mircea Toma
              Reporter:
              Mark Collette
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: