Author: trong.tran
Date: 2011-01-10 01:59:23 -0500 (Mon, 10 Jan 2011)
New Revision: 5712
Modified:
exo/portal/branches/3.1.x/docs/reference-guide/en/modules/PortalDevelopment/JavascriptConfiguration.xml
Log:
DOC-482 wrong documentation about Javascript configuration in GateIn
Modified:
exo/portal/branches/3.1.x/docs/reference-guide/en/modules/PortalDevelopment/JavascriptConfiguration.xml
===================================================================
---
exo/portal/branches/3.1.x/docs/reference-guide/en/modules/PortalDevelopment/JavascriptConfiguration.xml 2011-01-07
15:27:11 UTC (rev 5711)
+++
exo/portal/branches/3.1.x/docs/reference-guide/en/modules/PortalDevelopment/JavascriptConfiguration.xml 2011-01-10
06:59:23 UTC (rev 5712)
@@ -1,109 +1,100 @@
-<?xml version='1.0' encoding='utf-8' ?>
-<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- This document was created with Syntext Serna Free. --><!DOCTYPE section
PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % BOOK_ENTITIES SYSTEM "../../Reference_Guide.ent">
%BOOK_ENTITIES;
]>
<section id="sect-Reference_Guide-Javascript_Configuration">
- <title>Javascript Configuration</title>
- <para>
- Managing Javascript scripts in an application like &PRODUCT; is a critical part of
the configuration work.
+ <title>JavaScript Configuration</title>
+ <para>
+ Managing JavaScript in an application like &PRODUCT; is a critical part of the
configuration work.
Configuring the scripts correctly will result in a faster response time from the
portal.
- </para>
- <para>
- Every portlet can have its own javscript code but in many cases it is more convenient
to reuse some existing
+ </para>
+ <para>
+ Every portlet can have its own JavaScript code but in many cases, it is more convenient
to reuse some existing
shared libraries. For that reason, &PRODUCT; has a mechanism to easily register
the libraries that will be loaded
- when the first page will be rendered.
- </para>
- <para>
- To do so, every WAR deployed in &PRODUCT; can register the
<filename>.js</filename> files with the groovy script
-
<filename>WEB-INF/conf/script/groovy/JavascriptScript.groovy</filename>.
(TODO: this file doesn't seem to exist)
- </para>
- <para>
- The example file below is found in the 01eXoResources.war
- </para>
-
-<programlisting
role="JAVA">JavascriptService.addJavascript("eXo",
"/javascript/eXo.js", ServletContext);
-/* Animation Javascripts */
-JavascriptService.addJavascript("eXo.animation.ImplodeExplode",
"/javascript/eXo/animation/ImplodeExplode.js", ServletContext);
-/* Application descriptor */
-JavascriptService.addJavascript("eXo.application.ApplicationDescriptor",
"/javascript/eXo/application/ApplicationDescriptor.js", ServletContext);
-/* CORE Javascripts */
-JavascriptService.addJavascript("eXo.core.Utils",
"/javascript/eXo/core/Util.js", ServletContext);
-JavascriptService.addJavascript("eXo.core.DOMUtil",
"/javascript/eXo/core/DOMUtil.js", ServletContext);
-JavascriptService.addJavascript("eXo.core.Browser",
"/javascript/eXo/core/Browser.js", ServletContext);
-JavascriptService.addJavascript("eXo.core.MouseEventManager",
"/javascript/eXo/core/MouseEventManager.js", ServletContext);
-JavascriptService.addJavascript("eXo.core.UIMaskLayer",
"/javascript/eXo/core/UIMaskLayer.js", ServletContext);
-JavascriptService.addJavascript("eXo.core.Skin",
"/javascript/eXo/core/Skin.js", ServletContext);
-JavascriptService.addJavascript("eXo.core.DragDrop",
"/javascript/eXo/core/DragDrop.js", ServletContext);
-JavascriptService.addJavascript("eXo.core.TemplateEngine",
"/javascript/eXo/core/TemplateEngine.js", ServletContext);
-/* Widget Javascripts */
-JavascriptService.addJavascript("eXo.widget.UIWidget",
"/javascript/eXo/widget/UIWidget.js", ServletContext);
-JavascriptService.addJavascript("eXo.widget.UIAddWidget",
"/javascript/eXo/widget/UIAddWidget.js", ServletContext);
-JavascriptService.addJavascript("eXo.widget.UIExoWidget",
"/javascript/eXo/widget/UIExoWidget.js", ServletContext);
-/* Desktop Javascripts */
-JavascriptService.addJavascript("eXo.desktop.UIDockbar",
"/javascript/eXo/desktop/UIDockbar.js", ServletContext);
-JavascriptService.addJavascript("eXo.desktop.UIDesktop",
"/javascript/eXo/desktop/UIDesktop.js", ServletContext);
-/* WebUI Javascripts */
-JavascriptService.addJavascript("eXo.webui.UIItemSelector",
"/javascript/eXo/webui/UIItemSelector.js", ServletContext);
-JavascriptService.addJavascript("eXo.webui.UIForm",
"/javascript/eXo/webui/UIForm.js", ServletContext);
-JavascriptService.addJavascript("eXo.webui.UIPopup",
"/javascript/eXo/webui/UIPopup.js", ServletContext);
-JavascriptService.addJavascript("eXo.webui.UIPopupSelectCategory",
"/javascript/eXo/webui/UIPopupSelectCategory.js", ServletContext);
-JavascriptService.addJavascript("eXo.webui.UIPopupWindow",
"/javascript/eXo/webui/UIPopupWindow.js", ServletContext);
-JavascriptService.addJavascript("eXo.webui.UIVerticalScroller",
"/javascript/eXo/webui/UIVerticalScroller.js", ServletContext);
-JavascriptService.addJavascript("eXo.webui.UIHorizontalTabs",
"/javascript/eXo/webui/UIHorizontalTabs.js", ServletContext);
-JavascriptService.addJavascript("eXo.webui.UIPopupMenu",
"/javascript/eXo/webui/UIPopupMenu.js", ServletContext);
-JavascriptService.addJavascript("eXo.webui.UIDropDownControl",
"/javascript/eXo/webui/UIDropDownControl.js", ServletContext);
-/* Portal Javascripts */
-JavascriptService.addJavascript("eXo.portal.PortalHttpRequest",
"/javascript/eXo/portal/PortalHttpRequest.js", ServletContext);
-JavascriptService.addJavascript("eXo.portal.UIPortal",
"/javascript/eXo/portal/UIPortal.js", ServletContext);
-JavascriptService.addJavascript("eXo.portal.UIWorkspace",
"/javascript/eXo/portal/UIWorkspace.js", ServletContext);
-JavascriptService.addJavascript("eXo.portal.UIPortalControl",
"/javascript/eXo/portal/UIPortalControl.js", ServletContext);
-JavascriptService.addJavascript("eXo.portal.PortalDragDrop",
"/javascript/eXo/portal/PortalDragDrop.js", ServletContext);
-JavascriptService.addJavascript("eXo.portal.UIPortalNavigation",
"/javascript/eXo/portal/UIPortalNavigation.js", ServletContext);
-JavascriptService.addJavascript("eXo.portal.UIMaskWorkspace",
"/javascript/eXo/portal/UIMaskWorkspace.js", ServletContext);
-JavascriptService.addJavascript("eXo.portal.UIExoStartMenu",
"/javascript/eXo/portal/UIExoStartMenu.js", ServletContext);
-/* Desktop Javascripts 2 */
-JavascriptService.addJavascript("eXo.desktop.UIWindow",
"/javascript/eXo/desktop/UIWindow.js", ServletContext);
+ when every page is rendered.
+ </para>
+ <para>
+ To do so, every WAR deployed in &PRODUCT; can register the
<filename>.js</filename> files with the <emphasis
role="bold">gatein-resources.xml</emphasis> configuration
file.</para>
+ <para>
+ The example code snippet below is found in the <emphasis
role="bold">gatein-resources.xml</emphasis> in the <emphasis
role="bold">eXoResources.war </emphasis>file.</para>
+ <programlisting role="XML"><javascript>
+ <param>
+ <js-module>eXo</js-module>
+ <js-path>/javascript/eXo.js</js-path>
+ <js-priority>0</js-priority>
+ </param>
+</javascript>
+
+<!-- CORE Javascripts -->
+<javascript>
+ <param>
+ <js-module>eXo.core.Utils</js-module>
+ <js-path>/javascript/eXo/core/Util.js</js-path>
+ <js-priority>1</js-priority>
+ </param>
+ <param>
+ <js-module>eXo.core.DOMUtil</js-module>
+ <js-path>/javascript/eXo/core/DOMUtil.js</js-path>
+ <js-priority>1</js-priority>
+ </param>
+ <param>
+ <js-module>eXo.core.Browser</js-module>
+ <js-path>/javascript/eXo/core/Browser.js</js-path>
+ <js-priority>2</js-priority>
+ </param>
+ <param>
+ <js-module>eXo.core.MouseEventManager</js-module>
+
<js-path>/javascript/eXo/core/MouseEventManager.js</js-path>
+ </param>
+ <param>
+ <js-module>eXo.core.UIMaskLayer</js-module>
+ <js-path>/javascript/eXo/core/UIMaskLayer.js</js-path>
+ </param>
+ <param>
+ <js-module>eXo.core.Skin</js-module>
+ <js-path>/javascript/eXo/core/Skin.js</js-path>
+ </param>
+ <param>
+ <js-module>eXo.core.DragDrop</js-module>
+ <js-path>/javascript/eXo/core/DragDrop.js</js-path>
+ </param>
+ <param>
+ <js-module>eXo.core.DragDrop2</js-module>
+ <js-path>/javascript/eXo/core/DragDrop2.js</js-path>
+ </param>
+</javascript>
</programlisting>
- <para>
- Note that even registered dedicated javascripts will be merged into a single
<literal>merged.js</literal> file when the server loads. This reduces the
number of HTTP calls as seen in the home page source code:
- </para>
-
-<programlisting role="XML"><script
type="text/javascript"
src="/portal/javascript/merged.js"></script>
+ <para>
+ Note that registered JavaScript files will be merged into a single
<literal>merged.js</literal> file when the server loads. This reduces the
number of HTTP calls as seen in the home page source code:
+ </para>
+ <programlisting role="XML"><script
type="text/javascript"
src="/portal/javascript/merged.js"></script>
</programlisting>
- <para>
- Although this optimization is useful for a production environment, it may be easier to
deactivate this optimization while debugging javascript problems.
- </para>
- <para>
- To do this, set the java system property
<literal>exo.product.developing</literal> to
<literal>true</literal>.
- </para>
- <para>
- To see or use the merged file set this property to
<literal>false</literal>.
- </para>
- <para>
- The property can be passed as a JVM parameter with the
<literal>-D</literal> option in your <literal>GateIn.sh</literal>
or <literal>GateIn.bat</literal> startup script.
- </para>
- <para>
- Every javascript file is associated with a module name which acts as a namespace.
+ <para>
+ Although this optimization is useful for a production environment, it may be easier to
deactivate this optimization while debugging JavaScript problems.
+ </para>
+ <para>
+ To do this, set the java system property
<literal>exo.product.developing</literal> to
<literal>true</literal>.
+ GateIn provides two startup scripts that define this property in gatein-dev.sh (for
Linux, Mac) and gatein-dev.bat (for Windows).</para>
+ <para>
+ To generate the <literal>merged.js</literal> file, set this property to
<literal>false</literal>.
+ If the property is not set, the default value is false. </para>
+ <para>
+ The property can be passed as a JVM parameter with the
<literal>-D</literal> option in your <literal>GateIn.sh</literal>
or <literal>GateIn.bat</literal> startup script.
+ </para>
+ <para>
+ Every JavaScript file is associated with a module name which acts as a namespace.
- The module name is passed as a first parameter to JavascriptService.addJavascript()
function as in the following example:
- </para>
- <programlisting role="JAVA">
-JavascriptService.addJavascript("eXo.core.DragDrop",
- "/javascript/eXo/core/DragDrop.js", ServletContext);
- </programlisting>
- <para>
- Inside the associated javascript files, functions are exposed as global javascript
function variables using the module name.
- </para>
- <para> For example:</para>
- <programlisting role="JAVA">
+ </para>
+ <para>
+ Inside the associated JavaScript files, the eXo JavaScript objects are exposed as
global variables named after the module.</para>
+ <para> For example:</para>
+ <programlisting role="JAVA">
eXo.core.DragDrop = new DragDrop();
</programlisting>
- <para>
- It is also possible to use <literal>eXo.require()</literal> javascript
method to lazy load and evaluate some javascript code.
- This is quite useful for the portlet or widget applications that will use this
javascript only once. Otherwise,
- if the library is reusable in several places it is better to reference it in the
groovy file.
- </para>
+ <para>
+ It is also possible to use the <literal>eXo.require()</literal>method to
lazy load and evaluate some JavaScript code.
+ This is quite useful for the portlet or gadget applications that will use this
JavaScript only once. Otherwise,
+ if the library is reusable in several places, it is better to define it
in the <emphasis role="bold">gatein-resources.xml</emphasis> file.
+ </para>
</section>
-
-