[ 
https://issues.apache.org/jira/browse/JS2-1194?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Woonsan Ko resolved JS2-1194.
-----------------------------

    Fix Version/s: 2.2.2
       Resolution: Fixed

Fixed.

If a portlet definition has "jetui.refresh.page.on.add.portlet" metadata with 
value, "true", then the page will be refreshed when adding the portlet with 
toolbox portlet.

> Some Portlets which contain 'document.write()' js calls (e.g. GWT-based 
> portlet) is not rendered at first after adding the portlet.
> -----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: JS2-1194
>                 URL: https://issues.apache.org/jira/browse/JS2-1194
>             Project: Jetspeed 2
>          Issue Type: Bug
>    Affects Versions: 2.2.1
>            Reporter: Woonsan Ko
>            Assignee: Woonsan Ko
>             Fix For: 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:
>            /\b([a-z_A-Z$]\w*)\s*\.\s*(addEventListener|attachEvent)\s*\(/ 
>              ==> "jetspeed.postload_" + methodNm + "(" + nodeRef + "," + 
> script.substr(match.index + match[0].length)
>      b) Replace "document.write()" by a custom JS2 code:
>            /\b(document\s*.\s*write(ln)?)\s*\(/
>              ==> "jetspeed.postload_docwrite(" + script.substr(match.index + 
> match[0].length)
>      c) Replace "location.href = ..." by a custom JS2 code:
>            
> /(;\s|\s+)([a-z_A-Z$][\w.]*)\s*\.\s*(URL\s*|(location\s*(\.\s*href\s*){0,1}))=\s*(("[^"]*"|'[^']*'|[^;])[^;]*)/
>              ==> "jetspeed.setdoclocation(" + match[2] + ', "' + memberExpr + 
> '", (' + match[6] + '))' + script.substr(match.index + match[0].length)
>   - References: PortletWindow.src.js and core.src.js, APA-5, JS2-1063.
> 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.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscr...@portals.apache.org
For additional commands, e-mail: jetspeed-dev-h...@portals.apache.org

Reply via email to