Details
-
Type: Improvement
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 1.7
-
Fix Version/s: 1.7.2
-
Labels:None
-
Environment:IE 7
-
ICEsoft Forum Reference:
-
Affects:Documentation (User Guide, Ref. Guide, etc.)
-
Workaround Exists:Yes
-
Workaround Description:
Description
Because we don't have a component for adding scripts to pages, one technique that we've used in certain situations is to create an ice:outputText component bound to a backing bean that inserts the snippet of script dynamically. This can be especially useful in portlet situations where determining the URL of JavaScript resource can be tricky. The technique works fine in every browser that I tried except for IE 7. I've so far narrowed it down to the the following logic in the application.js file. I've added two logging statements to highlight the issue:
commandDispatcher.register('updates', function(element) {
$enumerate(element.getElementsByTagName('update')).each(function(updateElement) {
try {
var address = updateElement.getAttribute('address');
var update = new Ice.ElementModel.Update(updateElement);
//Logging added
logger.debug('applied update.asHTML(): ' + update.asHTML());
address.asExtendedElement().updateDOM(update);
//Logging added
logger.debug('address.asElement.outerHTML : ' + address.asElement().outerHTML);
scriptLoader.searchAndEvaluateScripts(address.asElement());
if (Ice.StateMon) {
Ice.StateMon.checkAll();
Ice.StateMon.rebuild();
}
} catch (e) {
logger.error('failed to insert element: ' + update.asString(), e);
}
});
});
When I run my simple test application, I get the following logging output:
Safari
[window.QPlE#1] : applied update.asHTML(): <span class="iceOutTxt" id="j_id6:j_id7:j_id13"><script type="text/javascript" language="javascript">alert('add 1213132969669');</script></span>
[window.QPlE#1] : address.asElement.outerHTML : <span class="iceOutTxt" id="j_id6:j_id7:j_id13"><script type="text/javascript" language="javascript">alert('add 1213132969669');</script></span>
IE 7
[window.ouab#1] : applied update.asHTML(): <span class="iceOutTxt" id="j_id6:j_id7:j_id13"><script type="text/javascript" language="javascript">alert('add 1213132260384');</script></span>
[window.ouab#1] : address.asElement.outerHTML : <SPAN class=iceOutTxt id=j_id6:j_id7:j_id13></SPAN>
It appears that, in IE7, it tries to apply the incoming update (a <span> that contains the <script> tag) but when it goes to look it up again (address.asElement()) the <script> section has been removed.
commandDispatcher.register('updates', function(element) {
$enumerate(element.getElementsByTagName('update')).each(function(updateElement) {
try {
var address = updateElement.getAttribute('address');
var update = new Ice.ElementModel.Update(updateElement);
//Logging added
logger.debug('applied update.asHTML(): ' + update.asHTML());
address.asExtendedElement().updateDOM(update);
//Logging added
logger.debug('address.asElement.outerHTML : ' + address.asElement().outerHTML);
scriptLoader.searchAndEvaluateScripts(address.asElement());
if (Ice.StateMon) {
Ice.StateMon.checkAll();
Ice.StateMon.rebuild();
}
} catch (e) {
logger.error('failed to insert element: ' + update.asString(), e);
}
});
});
When I run my simple test application, I get the following logging output:
Safari
[window.QPlE#1] : applied update.asHTML(): <span class="iceOutTxt" id="j_id6:j_id7:j_id13"><script type="text/javascript" language="javascript">alert('add 1213132969669');</script></span>
[window.QPlE#1] : address.asElement.outerHTML : <span class="iceOutTxt" id="j_id6:j_id7:j_id13"><script type="text/javascript" language="javascript">alert('add 1213132969669');</script></span>
IE 7
[window.ouab#1] : applied update.asHTML(): <span class="iceOutTxt" id="j_id6:j_id7:j_id13"><script type="text/javascript" language="javascript">alert('add 1213132260384');</script></span>
[window.ouab#1] : address.asElement.outerHTML : <SPAN class=iceOutTxt id=j_id6:j_id7:j_id13></SPAN>
It appears that, in IE7, it tries to apply the incoming update (a <span> that contains the <script> tag) but when it goes to look it up again (address.asElement()) the <script> section has been removed.
Issue Links
- depends on
-
ICE-1931 More efficient outputText mode
- Closed
Attaching a test case (minus the WEB-INF/lib directory contents).