Affects Version/s: 2.2.1
Fix Version/s: 2.2.2
This issue has been known for long time for client-side rendering modules, so there were some solutions.
However, we don't have any solution in JetUI yet.
GWT based portlet application should contain a js file, "...nocache.js", which contains "document.write()" calls. This call causes the weird page status after adding the portlet.
By the way, the Jetspeed-2 Desktop had a solution for this problem like the following:
- It retrieves the portlet rendered content from the /portlet pipeline.
- It inspects the content whether the content has <script> tags.
- If it contains a script tag with src attribute, it retrieves the real source content.
- It inspects each code line and replaces with the following rules:
a) Replace "addEventListener|attachEvent" by a custom JS2 code:
==> "jetspeed.postload_" + methodNm + "(" + nodeRef + "," + script.substr(match.index + match.length)
b) Replace "document.write()" by a custom JS2 code:
==> "jetspeed.postload_docwrite(" + script.substr(match.index + match.length)
c) Replace "location.href = ..." by a custom JS2 code:
==> "jetspeed.setdoclocation(" + match + ', "' + memberExpr + '", (' + match + '))' + script.substr(match.index + match.length)
- References: PortletWindow.src.js and core.src.js,
However, the solution provided by JS2 desktop has some caveats:
- Looks too hacky.
- If the script uses a different variable name for document, the current code could not detect it. (GWT does this: l = document; )
By the way, we could recommend some best practices for portlet development instead of fixing this problem inside JS2:
- A Portlet should not use "document.write()" calls; Instead, it is recommended to use Portlet 2.0 head contribution where possible.
- A Portlet should not use "addEventListener|attachEvent" calls; Instead, it is recommended to use higher level frameworks such as YUI3.
- It is not recommended for a Portlet to use "location.href = ...;".
Anyway, I don't have a clear idea to solve this problem yet.