Author: thomas.heute(a)jboss.com
Date: 2009-12-08 05:40:09 -0500 (Tue, 08 Dec 2009)
New Revision: 973
Modified:
portal/trunk/docs/reference-guide/en/modules/development/Accessing_User_Profile.xml
portal/trunk/docs/reference-guide/en/modules/development/Ajax_Loading_Mask_Layer_Deactivation.xml
portal/trunk/docs/reference-guide/en/modules/development/JavaScript_Inter_Application_Communication.xml
portal/trunk/docs/reference-guide/en/modules/development/Upload_Component.xml
Log:
Format doc
Modified:
portal/trunk/docs/reference-guide/en/modules/development/Accessing_User_Profile.xml
===================================================================
---
portal/trunk/docs/reference-guide/en/modules/development/Accessing_User_Profile.xml 2009-12-08
09:06:53 UTC (rev 972)
+++
portal/trunk/docs/reference-guide/en/modules/development/Accessing_User_Profile.xml 2009-12-08
10:40:09 UTC (rev 973)
@@ -2,61 +2,40 @@
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
]>
<section id="sect-Reference_Guide-Accessing_User_Profile">
- <!--
+ <title>Accessing User Profile</title>
+ <para>
+ To retrieve the logged in user you can do as follows :
+ </para>
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-
- --><title>Accessing User Profile</title>
- <para>
- To retrieve the logged in user you can do as follows :
+ <programlisting role="JAVA"><![CDATA[// Alternative context:
WebuiRequestContext context = WebuiRequestContext.getCurrentInstance() ;
+PortalRequestContext context = PortalRequestContext.getCurrentInstance() ;
+// Get the id of the user logged
+String userId = context.getRemoteUser();
+// Request the information from OrganizationService:
+OrganizationService orgService = getApplicationComponent(OrganizationService.class) ;
+if (userId != null)
+ {
+ User user = orgService.getUserHandler().findUserByName(userId) ;
+ if (user != null)
+ {
+ String firstName = user.getFirstName();
+ String lastName = user.getLastName();
+ String email = user.getEmail();
+ }
+}]]></programlisting>
+ <para>
+ Alternatives for retrieving the Organization Service
</para>
-
-<programlisting>// Alternative context: WebuiRequestContext context =
- WebuiRequestContext.getCurrentInstance() ;
- PortalRequestContext context = PortalRequestContext.getCurrentInstance() ;
- // Get the id of the user logged
- String userId = context.getRemoteUser();
- // Request the information from OrganizationService:
- OrganizationService orgService = getApplicationComponent(OrganizationService.class) ;
- if(userId!images/= null) {
- User user = orgService.getUserHandler().findUserByName(userId) ;
- if (user!images/= null) {
- String firstName = user.getFirstName();
- String lastName = user.getLastName();
- String email = user.getEmail();
- }
- }
-</programlisting>
- <para>
- Alternatives for retrieving the Organization Service
- </para>
- <orderedlist numeration="arabic">
- <listitem>
- <para>
- OrganizationService service = (OrganizationService)
ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(OrganizationService.class);
- </para>
- </listitem>
- <listitem>
- <para>
- OrganizationService service = (OrganizationService)
PortalContainer.getInstance().getComponentInstanceOfType(OrganizationService.class);
- </para>
- </listitem>
- </orderedlist>
+ <orderedlist>
+ <listitem>
+ <programlisting role="JAVA"><![CDATA[OrganizationService
service = (OrganizationService)
+
ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(OrganizationService.class);]]></programlisting>
+ </listitem>
+ <listitem>
+ <programlisting role="JAVA"><![CDATA[OrganizationService
service = (OrganizationService)
+
PortalContainer.getInstance().getComponentInstanceOfType(OrganizationService.class);]]></programlisting>
+ </listitem>
+ </orderedlist>
</section>
Modified:
portal/trunk/docs/reference-guide/en/modules/development/Ajax_Loading_Mask_Layer_Deactivation.xml
===================================================================
---
portal/trunk/docs/reference-guide/en/modules/development/Ajax_Loading_Mask_Layer_Deactivation.xml 2009-12-08
09:06:53 UTC (rev 972)
+++
portal/trunk/docs/reference-guide/en/modules/development/Ajax_Loading_Mask_Layer_Deactivation.xml 2009-12-08
10:40:09 UTC (rev 973)
@@ -1,125 +1,124 @@
<?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" [
]>
-<section
id="sect-Reference_Guide-Deactivation_of_the_Ajax_Loading_Mask_Layer">
- <!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-
- --><title>Deactivation of the Ajax Loading Mask Layer</title>
- <section
id="sect-Reference_Guide-Deactivation_of_the_Ajax_Loading_Mask_Layer-Overview">
- <title>Overview</title>
- <para>
- In this article, you will learn:
+<section
+ id="sect-Reference_Guide-Deactivation_of_the_Ajax_Loading_Mask_Layer">
+ <title>Deactivation of the Ajax Loading Mask Layer
+ </title>
+ <section
+
id="sect-Reference_Guide-Deactivation_of_the_Ajax_Loading_Mask_Layer-Overview">
+ <title>Overview</title>
+ <para>
+ In this article, you will learn:
</para>
- <itemizedlist>
- <listitem>
- <para>
- Purpose of ajax-loading mask.
+ <itemizedlist>
+ <listitem>
+ <para>
+ Purpose of ajax-loading mask.
</para>
- </listitem>
- <listitem>
- <para>
- How to deactivate ajax-loading mask.
+ </listitem>
+ <listitem>
+ <para>
+ How to deactivate ajax-loading mask.
</para>
- </listitem>
- <listitem>
- <para>
- Synchronous / Asynchronous issue.
+ </listitem>
+ <listitem>
+ <para>
+ Synchronous / Asynchronous issue.
</para>
- </listitem>
- </itemizedlist>
- </section>
-
- <section
id="sect-Reference_Guide-Deactivation_of_the_Ajax_Loading_Mask_Layer-Purpose_of_requirement">
- <title>Purpose of requirement</title>
- <itemizedlist>
- <listitem>
- <para>
- Loading mask layer is displayed after ajax-call for blocking GUI to prevent
user's action until the the ajax-request is completed.
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section
+
id="sect-Reference_Guide-Deactivation_of_the_Ajax_Loading_Mask_Layer-Purpose_of_requirement">
+ <title>Purpose of requirement</title>
+ <itemizedlist>
+ <listitem>
+ <para>
+ Loading mask layer is displayed after ajax-call for
+ blocking GUI to
+ prevent user's action until the the
+ ajax-request is
+ completed.
</para>
- </listitem>
- <listitem>
- <para>
- Sometimes portal needs to be ready for user instructions without waiting previous
instructions completed. So mask layer may need to be deactivated.
- </para>
- </listitem>
- </itemizedlist>
- </section>
-
- <section
id="sect-Reference_Guide-Deactivation_of_the_Ajax_Loading_Mask_Layer-How_to_deactivate_ajax_loading_mask_in_your_code">
- <title>How to deactivate ajax-loading mask in your code</title>
- <para>
- To generate script to make an asynchronous ajax-call, we use uicomponent.doAsync()
method instead of uicomponent.event() method.
+ </listitem>
+ <listitem>
+ <para>
+ Sometimes portal needs to be ready for user
+ instructions without waiting
+ previous instructions
+ completed. So mask layer may need
+ to be deactivated.
+ </para>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section
+
id="sect-Reference_Guide-Deactivation_of_the_Ajax_Loading_Mask_Layer-How_to_deactivate_ajax_loading_mask_in_your_code">
+ <title>How to deactivate ajax-loading mask in your code</title>
+ <para>
+ To generate script to make an asynchronous ajax-call, we use
+ uicomponent.doAsync() method instead of uicomponent.event()
+ method.
</para>
- <para>
- Here is an example:
+ <para>
+ Here is an example:
</para>
- <para>
- <a href="<%=uicomponent.doAsync(action, beanId,
params)%>" alt="">Asynchronous</a>
+ <programlisting><![CDATA[<a
href="<%=uicomponent.doAsync(action, beanId, params)%>"
alt="">Asynchronous</a>]]></programlisting>
+ <para>
+ Method doAsync() automatically adds a parameter into parameters
+ list. Parameter async
+ <emphasis>param = new Parameter(AJAX</emphasis>
+ ASYNC,"true"); (AJAX
+ <emphasis>ASYNC == "ajax</emphasis>
+ async")
+ </para>
+ <para>
+ After all, its call method event() to generate script that make Ajax
+ Request. This request is asynchronous and ajax-loading mask
+ will not displayed.
</para>
- <para>
- Method doAsync() automatically adds a parameter into parameters list. Parameter
async<emphasis>param = new Parameter(AJAX</emphasis>ASYNC,"true");
(AJAX<emphasis>ASYNC == "ajax</emphasis>async")
+ <note>
+ <orderedlist><listitem><para>
+ You still also make an asynchronous request by using method
+ uicomponent.event(). Using this way, you must add asyncparam
+ manually.</para></listitem>
+ <listitem><para>
+ GUI is blocked so that user can do only one action at a time
+ (Request seems to be synchronous). But in fact ajax request
+ always be asynchronous. See Synchronous issue section.
+ </para></listitem>
+ </orderedlist>
+ </note>
+ </section>
+
+ <section
+
id="sect-Reference_Guide-Deactivation_of_the_Ajax_Loading_Mask_Layer-Synchronous_issue">
+ <title>Synchronous issue</title>
+ <para>
+ Almost web browser such as (IE, Chrome, Safari .. ) support ajax requests
+ in two modes: Synchronous / Asynchronous with boolean
+ value of bAsyn parameter.
</para>
- <para>
- After all, its call method event() to generate script that make Ajax Request. This
request is asynchronous and ajax-loading mask will not displayed.
+ <programlisting>var bAsync = false; // Synchronous
+request.open(instance.method, instance.url, bAsync);</programlisting>
+ <para>
+ But in Mozilla Firefox versions prior to 3.5 it wouldn't support synchronous
request.
+ </para>
+ <programlisting>var bAsync = false; // Synchronous
+request.open(instance.method, instance.url, bAsync); // Firefox will not
execute</programlisting>
+ <para>
+ So bAsync is set to always be true (Ajax request to always be asynchronous).
+ </para>
+ <programlisting>// Asynchronous request
+request.open(instance.method, instance.url, true);
+</programlisting>
+ <para>
+ As a consequence that Ajax Request will always be asynchronous.
</para>
- <para>
- Note:
- </para>
- <para>
- 1. You still also make an asynchronous request by using method uicomponent.event(). By
this way, you must add asyncparam manually.
- </para>
- <para>
- 2. GUI is blocked so that user can do only one action at a time (Request seems to be
synchronous). But in fact ajax request always be asynchronous. See Synchronous issue
section.
- </para>
- </section>
-
- <section
id="sect-Reference_Guide-Deactivation_of_the_Ajax_Loading_Mask_Layer-Synchronous_issue">
- <title>Synchronous issue</title>
- <para>
- Almost web browser such as (IE, Chrome, Safari .. ) told that ajax request may used in
two modes: Synchronous / Asynchronous with boolean value of bAsyn parameter. View
reference.
- </para>
- <para>
- var bAsync = false; // Synchronous
- </para>
- <para>
- request.open(instance.method, instance.url, bAsync);
- </para>
- <para>
- But Mozilla say no. They doesn't support synchronous request. var bAsync = false;
// Synchronous
- </para>
- <para>
- request.open(instance.method, instance.url, bAsync); // Firefox will not execute
- </para>
- <para>
- So we decide to set bAsync always true (Ajax request always be asynchronous).
- </para>
- <para>
- // Asynchronous request
- </para>
- <para>
- request.open(instance.method, instance.url, true);
- </para>
- <para>
- It is cause that Ajax Request always be asynchronous.
- </para>
- </section>
+ </section>
</section>
Modified:
portal/trunk/docs/reference-guide/en/modules/development/JavaScript_Inter_Application_Communication.xml
===================================================================
---
portal/trunk/docs/reference-guide/en/modules/development/JavaScript_Inter_Application_Communication.xml 2009-12-08
09:06:53 UTC (rev 972)
+++
portal/trunk/docs/reference-guide/en/modules/development/JavaScript_Inter_Application_Communication.xml 2009-12-08
10:40:09 UTC (rev 973)
@@ -1,157 +1,231 @@
<?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" [
]>
-<section
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication">
- <!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-
- --><title>JavaScript Inter Application Communication</title>
- <section
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-Overview">
- <title>Overview</title>
- <para>
- This kind of communication is made to allow applications within a page to exchange
data. This library is made for broadcasting messages on topic. This is basically based on
3 functions : subscribe, publish and unsubscribe.
+<section
+ id="sect-Reference_Guide-JavaScript_Inter_Application_Communication">
+ <title>JavaScript Inter Application Communication</title>
+ <section
+
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-Overview">
+ <title>Overview</title>
+ <para>
+ This kind of communication is made to allow applications within a page to
+ exchange data. This library is made for broadcasting messages
+ on topic. This is basically based on 3 functions : subscribe,
+ publish and unsubscribe.
</para>
- <para>
- When you subscribe to a topic, you receive all the subtopic message. for example, if I
subscribe to "/GateIn/application", and an application send a message on
"/GateIn/application/map", i will receive it, but if another application send a
message on "/GateIn", i will not receive it.
+ <para>
+ When you subscribe to a topic, you receive all the subtopic message. for
+ example, if I subscribe to "/eXo/application", and an
+ application send a message on "/eXo/application/map", i will
+ receive it, but if another application send a message on
+ "/eXo", i will not receive it.
</para>
- </section>
-
- <section
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-Common_topics">
- <title>Common topics</title>
- <para>
- Stuff Goes Here?
+ </section>
+<!--
+ <section
+
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-Common_topics">
+ <title>Common topics</title>
+ <para>
+ Stuff Goes Here?
</para>
- </section>
-
- <section
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-GateIn">
- <title>/GateIn</title>
- <para>
- It contains all the events generated by the platform.
+ </section>
+ -->
+ <section
+
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-GateIn">
+ <title>/eXo</title>
+ <para>
+ It contains all the events generated by the platform.
</para>
- </section>
-
- <section
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-GateInportalnotification">
- <title>/GateIn/portal/notification</title>
- <para>
- When a message is sent on this topic, a popup message appears on the top right of the
screen.
+ </section>
+
+ <section
+
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-GateInportalnotification">
+ <title>/eXo/portal/notification
+ </title>
+ <para>
+ When a message is sent on this topic, a popup message appears on the top
+ right of the screen.
</para>
- </section>
-
- <section
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-GateInportalchangeTitle_not_implemented_yet">
- <title>/GateIn/portal/changeTitle (not implemented yet)</title>
- <para>
- Send a message on this channel to change (and to be notified) the title of the
portal.
+ </section>
+<!--
+ <section
+
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-GateInportalchangeTitle">
+ <title>/GateIn/portal/changeTitle (not
+ implemented yet)</title>
+ <para>
+ Send a message on this channel to change (and to be notified) the title
+ of the portal.
</para>
- </section>
-
- <section
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-GateInportalpageLoaded_not_implemented_yet">
- <title>/GateIn/portal/pageLoaded (not implemented yet)</title>
- <para>
- Receive a message when a page is loaded.
+ </section>
+
+ <section
+
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-GateInportalpageLoaded">
+ <title>/GateIn/portal/pageLoaded (not
+ implemented yet)</title>
+ <para>
+ Receive a message when a page is loaded.
</para>
- </section>
-
- <section
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-GateInportalpageUnloaded_not_implemented_yet">
- <title>/GateIn/portal/pageUnloaded (not implemented yet)</title>
- <para>
- Receive a message when a page is unloaded.
+ </section>
+
+ <section
+
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-GateInportalpageUnloaded">
+ <title>/eXo/portal/pageUnloaded (not
+ implemented yet)</title>
+ <para>
+ Receive a message when a page is unloaded.
</para>
- </section>
-
- <section
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-GateInapplicationapplicationLoaded_not_implemented_yet">
- <title>/GateIn/application/applicationLoaded (not implemented yet)</title>
- <para>
- Receive a message when an application is loaded in the page.
+ </section>
+
+ <section
+
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-GateInapplicationapplicationLoaded">
+ <title>/eXo/application/applicationLoaded
+ (not implemented yet)</title>
+ <para>
+ Receive a message when an application is loaded in the page.
</para>
- </section>
-
- <section
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-GateInapplicationapplicationUnloaded_not_implemented_yet">
- <title>/GateIn/application/applicationUnloaded (not implemented
yet)</title>
- <para>
- Receive a message when an application is unloaded in the page.
+ </section>
+
+ <section
+
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-GateInapplicationapplicationUnloaded">
+ <title>/eXo/application/applicationUnloaded
+ (not implemented yet)</title>
+ <para>
+ Receive a message when an application is unloaded in the page.
</para>
- </section>
-
- <section
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-Library">
- <title>Library</title>
- <para>
- The inter application communication
http://fisheye.exoplatform.org/projects/browse/projects/portal/trunk/web/...
- </para>
- </section>
-
- <section
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-Syntax">
- <title>Syntax</title>
-
-<programlisting>subscribe is used to subscribe a callback to a topic
-*Parameters:*
-* topic is the topic that will be listened
-* obj is the context object
-* funcName is the name of the function of obj to call when a message is received on the
topic
-funcName have to be a function that take an Object in parameter. the event received have
this format:
-{code:javascript}
-{
+ </section>
+ -->
+
+ <section
+
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-Library">
+ <title>Library</title>
+ <para>
+ The inter application communication library can be found in
+
<filename>01eXoResources.war:/javascript/eXo/core/Topic.js</filename>
+ </para>
+ <programlisting><![CDATA[/**
+ * publish is used to publish an event to the other subscribers to the given channels
+ * @param {Object} senderId is a string that identify the sender
+ * @param {String} topic is the topic that the message will be published
+ * @param {Object} message is the message that's going to be delivered to the
subscribers to the topic
+ */
+Topic.prototype.publish = function(/*Object*/ senderId, /*String*/ topicName, /*Object*/
message ) { ... }
+
+/**
+ * isSubscribed is used to check if a function receive the events from a topic
+ * @param {String} topic The topic.
+ * @param {Function} func is the name of the function of obj to call when a message is
received on the topic
+ */
+Topic.prototype.isSubscribed = function(/*String*/ topic, /*Function*/ func) { ... }
+
+/**
+ * subscribe is used to subscribe a callback to a topic
+ * @param {String} topic is the topic that will be listened
+ * @param {Function} func is the name of the function of obj to call when a message is
received on the topic
+ *
+ * func is a function that take a Object in parameter. the event received have this
format:
+ * {senderId:senderId, message:message, topic: topic}
+ *
+ */
+Topic.prototype.subscribe = function(/*String*/ topic, /*Function*/ func) { ... }
+
+/**
+ * unsubscribe is used to unsubscribe a callback to a topic
+ * @param {String} topic is the topic
+ * @param {Object} id is the id of the listener we want to unsubscribe
+ */
+Topic.prototype.unsubscribe = function(/*String*/ topic, /*Object*/ id) { ... }
+
+Topic.prototype.initCometdBridge = function() { ... }]]></programlisting>
+ </section>
+
+ <section
+
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-Syntax">
+ <title>Syntax</title>
+
+ <para><literal>subscribe</literal> is used to subscribe a
callback to a topic.
+ Parameters:
+ <itemizedlist>
+ <listitem><para><literal>topic</literal> is the topic
that will be listened</para></listitem>
+ <listitem><para><literal>func</literal> is the name of
the function of obj to call when a message is received on the topic.
+ It has to be a function that take an Object in parameter. the event received
have this format:
+ <programlisting>{
senderId:senderId,
message:message,
topic: topic
-}
-</programlisting>
-
-<programlisting>publish is used to publish an event to the other subscribers to the
given channels
-*Parameters:*
-* senderId is a string that identify the sender
-* topic is the topic that the message will be published
-* message is the message that's going to be delivered to the subscribers to the
topic
-</programlisting>
- <para>
- unsubscribe is used to unsubscribe a callback to a topic
- </para>
- <itemizedlist>
- <listitem>
- <para>
- Parameters:
- </para>
- </listitem>
- <listitem>
- <para>
- topic is the topic that will be unsubscribe
- </para>
- </listitem>
- <listitem>
- <para>
- obj is the context object
- </para>
- </listitem>
- <listitem>
- <para>
- funcName function name givent at the previous subscribe
- </para>
- </listitem>
- </itemizedlist>
- </section>
-
- <section
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-Example">
- <title>Example</title>
- <para>
- <ulink
url="http://fisheye.exoplatform.org/projects/browse/projects/portal/...
Demo</ulink>
- </para>
- </section>
+}</programlisting>
+ </para></listitem>
+ </itemizedlist>
+ </para>
+ <para><literal>publish</literal> is used to publish an event to
the other subscribers to the given channels.
+ Parameters:
+ <itemizedlist>
+ <listitem><para><literal>senderId</literal> is a string
that identify the sender</para></listitem>
+ <listitem><para><literal>topicName</literal> is the
topic that the message will be published</para></listitem>
+ <listitem><para><literal>message</literal> is the
message that's going to be delivered to the subscribers to the
topic</para></listitem>
+ </itemizedlist>
+ </para>
+ <para><literal>unsubscribe</literal> is used to unsubscribe a
callback to a topic
+ Parameters:
+ <itemizedlist>
+ <listitem><para><literal>topic</literal> is the topic
that will be unsubscribe</para></listitem>
+ <listitem><para><literal>id</literal> is the context
object</para></listitem>
+ </itemizedlist>
+ </para>
+ </section>
+
+ <section
+
id="sect-Reference_Guide-JavaScript_Inter_Application_Communication-Example">
+ <title>Example</title>
+ <programlisting role="HTML"><![CDATA[<%@ taglib
uri="http://java.sun.com/portlet" prefix="portlet" %>
+<portlet:defineObjects/>
+<div>
+ <p>
+ Received messages:
+ <div id="received_<portlet:namespace/>">
+
+ </div>
+ </p>
+
+ <p>
+ Send message:
+ <input type="text" id="msg_<portlet:namespace/>"/>
<a href="#"
onclick="send_<portlet:namespace/>();">send</a>
+ </p>
+</div>
+
+<script type="text/javascript">
+
+ Function.prototype.bind = function(object) {
+ var method = this;
+ return function() {
+ method.apply(object, arguments);
+ }
+ }
+
+ function send_<portlet:namespace/>() {
+ var msg = document.getElementById("msg_<portlet:namespace/>").value;
+ eXo.core.Topic.publish("<portlet:namespace/>", "/demo",
msg);
+ }
+
+ function Listener_<portlet:namespace/>(){
+
+ }
+
+ Listener_<portlet:namespace/>.prototype.receiveMsg = function(event) {
+ document.getElementById("received_<portlet:namespace/>").innerHTML =
+ document.getElementById("received_<portlet:namespace/>").innerHTML
+ "<br />* " +
+ event.senderId + ": " + event.message;
+ }
+
+ function init_<portlet:namespace/>() {
+ var listener_<portlet:namespace/> = new Listener_<portlet:namespace/>();
+ eXo.core.Topic.subscribe("/demo",
listener_<portlet:namespace/>.receiveMsg.bind(listener_<portlet:namespace/>));
+ }
+
+ init_<portlet:namespace/>();
+</script>]]></programlisting>
+ </section>
+
</section>
Modified: portal/trunk/docs/reference-guide/en/modules/development/Upload_Component.xml
===================================================================
---
portal/trunk/docs/reference-guide/en/modules/development/Upload_Component.xml 2009-12-08
09:06:53 UTC (rev 972)
+++
portal/trunk/docs/reference-guide/en/modules/development/Upload_Component.xml 2009-12-08
10:40:09 UTC (rev 973)
@@ -2,149 +2,142 @@
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
]>
<section id="sect-Reference_Guide-Upload_Component">
- <!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-
- --><title>Upload Component</title>
- <section id="sect-Reference_Guide-Upload_Component-Overview">
- <title>Overview</title>
- <para>
- In this article, you will learn how to :
+ <title>Upload Component</title>
+ <section id="sect-Reference_Guide-Upload_Component-Overview">
+ <title>Overview</title>
+ <para>
+ In this article, you will learn how to :
</para>
- <itemizedlist>
- <listitem>
- <para>
- configure the Upload service
+ <itemizedlist>
+ <listitem>
+ <para>
+ configure the Upload service
</para>
- </listitem>
- <listitem>
- <para>
- add a default upload size limit
+ </listitem>
+ <listitem>
+ <para>
+ add a default upload size limit
</para>
- </listitem>
- <listitem>
- <para>
- use the Upload component in your application, with a specific upload size limit
+ </listitem>
+ <listitem>
+ <para>
+ use the Upload component in your application, with a specific upload
+ size limit
</para>
- </listitem>
- <listitem>
- <para>
- clean the service when the upload finishes
+ </listitem>
+ <listitem>
+ <para>
+ clean the service when the upload finishes
</para>
- </listitem>
- </itemizedlist>
- <para>
- The size limit feature is available since Portal 2.5.3
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section id="sect-Reference_Guide-Upload_Component-Upload_Service">
+ <title>Upload Service</title>
+ <para>
+ The service is defined by the class :
+ org.exoplatform.upload.UploadService;
</para>
- </section>
-
- <section id="sect-Reference_Guide-Upload_Component-Upload_Service">
- <title>Upload Service</title>
- <para>
- The service is defined by the class : org.exoplatform.upload.UploadService;
+ <para>
+ You can configure it with the following xml code :
</para>
- <para>
- You can configure it with the following xml code :
- </para>
-
-<programlisting><component>
- <type>org.exoplatform.upload.UploadService</type>
- <init-params>
- <value-param>
- <name>upload.limit.size</name>
- <description>Maximum size of the file to upload in
MB</description>
- <value>10</value>
- </value-param>
- </init-params>
- </component>
+
+ <programlisting role="XML"><![CDATA[<component>
+ <type>org.exoplatform.upload.UploadService</type>
+ <init-params>
+ <value-param>
+ <name>upload.limit.size</name>
+ <description>Maximum size of the file to upload in MB</description>
+ <value>10</value>
+ </value-param>
+ </init-params>
+ </component>]]>
</programlisting>
- <para>
- As you can see, you can configure a default upload size limit for the service. The
value unit is in MegaBytes. This limit will be used by default by all applications if no
specific limit is set. You will see in the next chapter how to set a different limit for
your application.
+ <para>
+ As you can see, you can configure a default upload size limit for the
+ service. The value unit is in MegaBytes. This limit will be
+ used by default by all applications if no specific limit is
+ set. You will see in the next chapter how to set a different
+ limit for your application.
</para>
- <para>
- If you set the value at 0, the upload size will be unlimited.
+ <para>
+ If you set the value at 0, the upload size will be unlimited.
</para>
- </section>
-
- <section
id="sect-Reference_Guide-Upload_Component-How_to_use_the_upload_component_in_your_application">
- <title>How to use the upload component in your application</title>
- <para>
- To use the component, you must create an object of type
org.exoplatform.webui.form.UIFormUploadInput, using one of the two available constructors
:
+ </section>
+
+ <section
+
id="sect-Reference_Guide-Upload_Component-How_to_use_the_upload_component_in_your_application">
+ <title>How to use the upload component in your application
+ </title>
+ <para>
+ To use the component, you must create an object of type
+ org.exoplatform.webui.form.UIFormUploadInput, using one of the
+ two available constructors :
</para>
-
-<programlisting>public UIFormUploadInput(String name, String bindingExpression)
-</programlisting>
- <para>
- or:
+ <programlisting>public UIFormUploadInput(String name, String
bindingExpression)</programlisting>
+ <para>
+ or:
</para>
-
-<programlisting>public UIFormUploadInput(String name, String bindingExpression, int
limit)
-</programlisting>
- <para>
- Here is an example using the second form : {code} PortletRequestContext pcontext =
(PortletRequestContext)WebuiRequestContext.getCurrentInstance(); PortletPreferences
portletPref = pcontext.getRequest().getPreferences(); int limitMB =
Integer.parseInt(portletPref.getValue("uploadFileSizeLimitMB",
"").trim()); UIFormUploadInput uiInput = new
UIFormUploadInput("upload", "upload", limitMB) ;
+ <programlisting>public UIFormUploadInput(String name, String
bindingExpression, int limit)</programlisting>
+ <para>
+ Here is an example using the second form :
+ </para>
+ <programlisting role="JAVA"><![CDATA[PortletRequestContext
pcontext = (PortletRequestContext)WebuiRequestContext.getCurrentInstance();
+PortletPreferences portletPref = pcontext.getRequest().getPreferences();
+int limitMB = Integer.parseInt(portletPref.getValue("uploadFileSizeLimitMB",
"").trim());
+UIFormUploadInput uiInput = new UIFormUploadInput("upload", "upload",
limitMB);
+]]></programlisting>
+
+ <para>
+ To get the limit from the xml configuration, you can add this piece of code in
the files portlet.xml or portlet-preferences.xml :
+ </para>
+ <programlisting role="XML"><![CDATA[<preference>
+ <name>uploadFileSizeLimitMB</name>
+ <value>30</value>
+ <read-only>false</read-only>
+</preference>]]></programlisting>
+ <para>
+ Again, a 0 value means unlimited upload size, and the value unit is set in
+ MegaBytes.
</para>
-
-<programlisting>
-To get the limit from the xml configuration, you can add this piece of code in the files
portlet.xml or portlet-preferences.xml :
-{code:xml}
-<preference>
- <name>uploadFileSizeLimitMB</name>
- <value>30</value>
- <read-only>false</read-only>
-</preference>
-</programlisting>
- <para>
- Again, a 0 value means unlimited upload size, and the value unit is set in MegaBytes.
+ <para>
+ To get the uploaded data use the
<literal>getUploadDataAsStream()</literal> method:
+ </para>
+ <programlisting role="JAVA"><![CDATA[UIFormUploadInput input =
(UIFormUploadInput)uiForm.getUIInput("upload");
+InputStream inputStream = input.getUploadDataAsStream();
+...
+jcrData.setValue(inputStream);]]></programlisting>
+ <para>Clean the uploaded file</para>
+ <para>
+ The upload service stores a temporary file on the filesystem during the
+ process. When the upload is finished, you must clean the
+ service in order to :
</para>
- <para>
- To get the uploaded data use the ~~getUploadDataAsStream()~~ method: {code}
UIFormUploadInput input = (UIFormUploadInput)uiForm.getUIInput("upload");
InputStream inputStream = input.getUploadDataAsStream(); ... jcrData.setValue(inputStream)
; {code}
- </para>
- <para>
- 1 Clean the uploaded file
- </para>
- <para>
- The upload service stores a temporary file on the filesystem during the process. When
the upload is finished, you must clean the service in order to :
- </para>
- <itemizedlist>
- <listitem>
- <para>
- delete the temporary file
+ <itemizedlist>
+ <listitem>
+ <para>
+ delete the temporary file
</para>
- </listitem>
- <listitem>
- <para>
- delete the classes used for the upload
+ </listitem>
+ <listitem>
+ <para>
+ delete the classes used for the upload
</para>
- </listitem>
- </itemizedlist>
- <para>
- To do that, use the ~~removeUpload()~~ method defined in the upload service, like this
:
+ </listitem>
+ </itemizedlist>
+ <para>
+ To do that, use the<literal>removeUpload()</literal> method defined
in the upload
+ service, like this :
</para>
-
-<programlisting>UploadService uploadService =
uiForm.getApplicationComponent(UploadService.class) ;
+
+ <programlisting role="JAVA"><![CDATA[UploadService uploadService
= uiForm.getApplicationComponent(UploadService.class) ;
UIFormUploadInput uiChild = uiForm.getChild(UIFormUploadInput.class) ;
-uploadService.removeUpload(uiChild.getUploadId()) ;
-</programlisting>
- <para>
- Be sure to get and save the file in a JCR node <emphasis
role="bold">before</emphasis> you clean the service
- </para>
- </section>
+uploadService.removeUpload(uiChild.getUploadId()) ;]]></programlisting>
+ <para>
+ Be sure to get and save the file <emphasis
role="bold">before</emphasis> you clean the service
+ </para>
+ </section>
</section>