ICEfaces
  1. ICEfaces
  2. ICE-2542

Portlet-friendly injection of 3rd party JavaScript

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7DR#3
    • Fix Version/s: 1.7Beta1, 1.7
    • Component/s: Framework, ICE-Components
    • Labels:
      None
    • Environment:
      portal portlet

      Description

      Some components require 3rd party JavaScript libraries to be available to function properly. Current examples would be the Rich Text Editor (based on FCKEdit) and GMap (Google Maps) components. At the moment, we inject these additional scripts using techniques that enhance the <head>. However, in a portlet environment, the code path that does this injection is not executed. With ICEfaces, portlets are treated as page fragments and so the logic for enhancing the <head> is never run.

        Issue Links

          Activity

          Deryk Sinotte created issue -
          Hide
          Deryk Sinotte added a comment -

          I did notice in the NormalModeSerializer the following snippet:

          if (isFragment(requestMap)) {
          if (log.isDebugEnabled())

          { log.debug("treating request as a fragment"); }

          Node body = DOMUtils.getChildByNodeName(
          document.getDocumentElement(), "body");
          if (null != body)

          { //insert a containing element for bridge anchoring writer.write("<div>\n"); //We need to include, for now, ICE_EXTRAS all the time to //ensure that it is available. writer.write(makeScriptEntry(JavascriptContext.ICE_BRIDGE)); writer.write(makeScriptEntry(JavascriptContext.ICE_EXTRAS)); writer.write(DOMUtils.childrenToString(body)); writer.write("</div>\n"); }

          This does get run in portlets (which are basically treated as fragments). So I added this:

          String[] jsLibs = JavascriptContext.getIncludedLibs(context);
          for (int i = 0; i < jsLibs.length; i++)

          { String jsLib = jsLibs[i]; writer.write(makeScriptEntry(jsLib)); }

          Which seemed to get the Google components working as that is how they add the script library. But our Rich Text Component seems to do something else (not using the JavaScriptContext).

          Show
          Deryk Sinotte added a comment - I did notice in the NormalModeSerializer the following snippet: if (isFragment(requestMap)) { if (log.isDebugEnabled()) { log.debug("treating request as a fragment"); } Node body = DOMUtils.getChildByNodeName( document.getDocumentElement(), "body"); if (null != body) { //insert a containing element for bridge anchoring writer.write("<div>\n"); //We need to include, for now, ICE_EXTRAS all the time to //ensure that it is available. writer.write(makeScriptEntry(JavascriptContext.ICE_BRIDGE)); writer.write(makeScriptEntry(JavascriptContext.ICE_EXTRAS)); writer.write(DOMUtils.childrenToString(body)); writer.write("</div>\n"); } This does get run in portlets (which are basically treated as fragments). So I added this: String[] jsLibs = JavascriptContext.getIncludedLibs(context); for (int i = 0; i < jsLibs.length; i++) { String jsLib = jsLibs[i]; writer.write(makeScriptEntry(jsLib)); } Which seemed to get the Google components working as that is how they add the script library. But our Rich Text Component seems to do something else (not using the JavaScriptContext).
          Deryk Sinotte made changes -
          Field Original Value New Value
          Link This issue blocks ICE-2311 [ ICE-2311 ]
          Deryk Sinotte made changes -
          Link This issue is duplicated by ICE-2382 [ ICE-2382 ]
          Ken Fyten made changes -
          Fix Version/s 1.7 [ 10080 ]
          Assignee Mircea Toma [ mircea.toma ]
          Ken Fyten made changes -
          Assignee Priority P1
          Hide
          Mircea Toma added a comment -

          Insert page references directly into the document.

          Show
          Mircea Toma added a comment - Insert page references directly into the document.
          Mircea Toma made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #15530 Thu Jan 10 12:21:37 MST 2008 deryk.sinotte ICE-2542: Removed an unnecessary conditional check that prevented component-specific libraries from being added for portlets.
          Files Changed
          Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/context/DOMResponseWriter.java
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #15531 Thu Jan 10 12:34:30 MST 2008 deryk.sinotte ICE-2542: Uncommenting the configuration of GMap and Rich Text Editor components for the portal version of Component Showcase.
          Files Changed
          Commit graph MODIFY /icefaces/trunk/icefaces/samples/component-showcase/portlet/conf/liferay/liferay-display.xml
          Commit graph MODIFY /icefaces/trunk/icefaces/samples/component-showcase/portlet/conf/portlet.xml
          Commit graph MODIFY /icefaces/trunk/icefaces/samples/component-showcase/portlet/conf/liferay/liferay-portlet.xml
          Hide
          Deryk Sinotte added a comment -

          There are still some issues. The Rich Text Editor appears to work but it uses a slightly different mechanism to inject it's scripts. The Google Map components use the JavaScriptContext API and the libraries are not being added. Re-opening.

          Show
          Deryk Sinotte added a comment - There are still some issues. The Rich Text Editor appears to work but it uses a slightly different mechanism to inject it's scripts. The Google Map components use the JavaScriptContext API and the libraries are not being added. Re-opening.
          Deryk Sinotte made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Hide
          Deryk Sinotte added a comment -

          The code in the DOMResponseWriter for adding the component-specific libraries is making a conditional check before executing the code. The check fails in a portlet environment. Ive checked with Mircea and it seems that the conditional logic is no longer required. I'll remove it, test, and check it in if everything works out.

          Show
          Deryk Sinotte added a comment - The code in the DOMResponseWriter for adding the component-specific libraries is making a conditional check before executing the code. The check fails in a portlet environment. Ive checked with Mircea and it seems that the conditional logic is no longer required. I'll remove it, test, and check it in if everything works out.
          Hide
          Deryk Sinotte added a comment -

          Looks like does that trick. The revision has been checked in. Resolving as fixed.

          Show
          Deryk Sinotte added a comment - Looks like does that trick. The revision has been checked in. Resolving as fixed.
          Deryk Sinotte made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Ken Fyten made changes -
          Fix Version/s 1.7Beta1 [ 10121 ]
          Fix Version/s 1.7 [ 10080 ]
          Ken Fyten made changes -
          Fix Version/s 1.7 [ 10080 ]
          Ken Fyten made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Assignee Priority P1
          Assignee Mircea Toma [ mircea.toma ]
          Hide
          Niels Frydenholm added a comment -

          I have a problem with libraries not being loaded in a portlet after navigation.
          See this post http://www.icefaces.org/JForum/posts/list/0/12161.page#48507

          I think it is related to this issue.

          Show
          Niels Frydenholm added a comment - I have a problem with libraries not being loaded in a portlet after navigation. See this post http://www.icefaces.org/JForum/posts/list/0/12161.page#48507 I think it is related to this issue.
          Hide
          Juan Villanueva added a comment -

          Can somebody show me the code changed in DOMresponseWriter for the issue with Gmap?

          Thanks

          Show
          Juan Villanueva added a comment - Can somebody show me the code changed in DOMresponseWriter for the issue with Gmap? Thanks

            People

            • Assignee:
              Unassigned
              Reporter:
              Deryk Sinotte
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: