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
Activity
- All
- Comments
- History
- Activity
- Remote Attachments
- Subversion
Deryk Sinotte
created issue -
Deryk Sinotte
made changes -
Field | Original Value | New Value |
---|---|---|
Attachment | outputjs.zip [ 11061 ] |
Deryk Sinotte
made changes -
Summary | Cannot use ice:outputText componet to render our snippets of JavaScript in IE 7 | Add "nospan" attribute to ice:outputText component |
Deryk Sinotte
made changes -
Workaround Description |
<ice:outputText escape="false" value="blah #{test.script}" styleClass="inlineJS"/> Adding some text in front seems to fix the problem with IE without affecting Firefox and Safari. Applying the style assures that the span won't actually be displayed. I tried the following without success. It seemed that the style wasn't properly rendered out. <ice:outputText escape="false" value="blah #{test.script}" style="display:none;"/> |
|
Workaround Exists | [Yes] |
Deryk Sinotte
made changes -
Workaround Description |
<ice:outputText escape="false" value="blah #{test.script}" styleClass="inlineJS"/> Adding some text in front seems to fix the problem with IE without affecting Firefox and Safari. Applying the style assures that the span won't actually be displayed. I tried the following without success. It seemed that the style wasn't properly rendered out. <ice:outputText escape="false" value="blah #{test.script}" style="display:none;"/> |
Do two things to your outputText: 1) Add some text in front of the bean binding 2) Set the visible attribute to false (so the text won't display) <ice:outputText escape="false" value="blah #{test.script}" visible="false"/> Adding some text in front seems to fix the problem with IE without affecting Firefox and Safari. Setting visible to false ensures that the span and contents aren't displayed. I tried using style="display:none;" directly in the component without success. It seemed that the style wasn't properly rendered out. Setting visible to false actually sets this style for you. |
Deryk Sinotte
made changes -
Status | Open [ 1 ] | Resolved [ 5 ] |
Resolution | Won't Fix [ 2 ] |
Deryk Sinotte
made changes -
Assignee | Deryk Sinotte [ deryk.sinotte ] |
Ken Fyten
made changes -
Resolution | Won't Fix [ 2 ] | |
Status | Resolved [ 5 ] | Reopened [ 4 ] |
Ken Fyten
made changes -
Status | Reopened [ 4 ] | Resolved [ 5 ] |
Fix Version/s | 1.7.2 [ 10130 ] | |
Affects | [Documentation (User Guide, Ref. Guide, etc.)] | |
Resolution | Fixed [ 1 ] |
Ken Fyten
made changes -
Issue Type | Bug [ 1 ] | Improvement [ 4 ] |
Ken Fyten
made changes -
Status | Resolved [ 5 ] | Closed [ 6 ] |
Assignee | Deryk Sinotte [ deryk.sinotte ] |