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:
When it processes the view for the Context Menu, the list of coalesced resources is:
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.
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:
So it's very specific to the combination of Context Menu + File Entry + coalescing together.