[gatein-commits] gatein SVN: r9114 - in epp/docs/branches/6.0/Reference_Guide/en-US/modules: PortalDevelopment and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Feb 4 18:31:31 EST 2013


Author: rdickens
Date: 2013-02-04 18:31:31 -0500 (Mon, 04 Feb 2013)
New Revision: 9114

Added:
   epp/docs/branches/6.0/Reference_Guide/en-US/modules/PortalDevelopment/UploadComponent.xml
Modified:
   epp/docs/branches/6.0/Reference_Guide/en-US/modules/PortalDevelopment.xml
Log:
Incorporated content from: https://docs.jboss.org/author/display/GTNPORTAL35/Upload+Component, up to version 3

Added: epp/docs/branches/6.0/Reference_Guide/en-US/modules/PortalDevelopment/UploadComponent.xml
===================================================================
--- epp/docs/branches/6.0/Reference_Guide/en-US/modules/PortalDevelopment/UploadComponent.xml	                        (rev 0)
+++ epp/docs/branches/6.0/Reference_Guide/en-US/modules/PortalDevelopment/UploadComponent.xml	2013-02-04 23:31:31 UTC (rev 9114)
@@ -0,0 +1,189 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!DOCTYPE chapter 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;
+]>
+<chapter id="chap-Reference_Guide-Upload_Component">
+  <remark>Source: https://docs.jboss.org/author/display/GTNPORTAL35/Upload+Component. Incorporated up to version: 3</remark>
+  <title>Upload Component</title>
+  <section id="sect-Reference_Guide-Upload_Component-Overview">
+      <title>Overview</title>
+      <para>
+        In this section, you will learn how to configure the
+        <emphasis role="italics">Upload service</emphasis>
+        that is defined by the
+        <code>org.exoplatform.upload.UploadService</code>
+        class.
+      </para>
+      <para>This can be configured with the following XML code:</para>
+      <informalexample>
+        <programlisting language="XML">
+   &lt;component&gt;
+     &lt;type&gt;org.exoplatform.upload.UploadService&lt;/type&gt;
+     &lt;init-params&gt;
+       &lt;value-param&gt;
+         &lt;name&gt;upload.limit.size&lt;/name&gt;
+         &lt;description&gt;Maximum size of the file to upload in MB&lt;/description&gt;
+         &lt;value&gt;10&lt;/value&gt;
+       &lt;/value-param&gt;
+     &lt;/init-params&gt;
+   &lt;/component&gt;
+</programlisting>
+      </informalexample>
+      <para>This code allows uploading files with the default size limit (10MB). The default value unit is in megabytes.</para>
+      <para>This limitation will be used by default by all applications if no application-specific limit is set. Setting a different limit for applications is discussed in a later section.</para>
+      <para>
+        If the value is set to
+        <code>0</code>
+        , the upload size is unlimited.
+      </para>
+      </section>
+      <section id="sid-54264598_UploadComponent-Usetheuploadcomponent">
+        
+        <title>Use the upload component</title>
+        <orderedlist>
+          <listitem>
+            <para>
+              Create an
+              <code>org.exoplatform.webui.form.input.UIUploadInput</code>
+              object type by using one of three following constructors:
+            </para>
+            <itemizedlist>
+              <listitem>
+                <para>The default constructor that allows uploading the file with the size of 10 MB.</para>
+                <informalexample>
+                  <programlisting language="Java">
+public UIUploadInput(String name, String bindingExpression, int limitFile)
+</programlisting>
+                </informalexample>
+              </listitem>
+              <listitem>
+                <para>
+                  This constructor allows you to customize the size limit of uploaded files by using the
+                  <code>limitSize</code>
+                  parameter. The default value unit is in megabytes.
+                </para>
+                <informalexample>
+                  <programlisting language="Java">
+public UIUploadInput(String name, String bindingExpression,int limitFile, int limitSize)
+</programlisting>
+                </informalexample>
+              </listitem>
+              <listitem>
+                <para>
+                  This constructor allows you to customize the size limit and the value unit by using the
+                  <code>limitSize</code>
+                  and
+                  <code>unit</code>
+                  parameters respectively.
+                  
+                  In JBoss Portal Platform, you can set the value unit to megabytes (MB), kilobytes (KB) or gigabytes (GB).
+                </para>
+                <informalexample>
+                  <programlisting>
+public UIUploadInput(String name, String bindingExpression, int limitFile, int limitSize, UploadUnit unit)
+</programlisting>
+                </informalexample>
+                <para>The following is an example using the third form:</para>
+                <informalexample>
+                  <programlisting language="Java">
+PortletRequestContext pcontext = (PortletRequestContext)WebuiRequestContext.getCurrentInstance();
+PortletPreferences portletPref = pcontext.getRequest().getPreferences();
+int limitFile = Integer.parseInt(portletPref.getValue("uploadFileLimit", "1").trim());
+int limitSize = Integer.parseInt(portletPref.getValue("uploadFileSizeLimit", "").trim());
+UploadUnit limitUnit = UploadUnit.valueOf(portletPref.getValue("uploadFileLimitUnit", "MB").trim());
+UIUploadInput uiInput = new UIUploadInput("upload", "upload", limitFile, limitSize, limitUnit);
+</programlisting>
+                </informalexample>
+              </listitem>
+            </itemizedlist>
+          </listitem>
+          <listitem>
+            <para>
+              Obtain the limit from the
+              <code>XML</code>
+              configuration by adding the following code to either
+              <code>portlet.xml</code>
+              or
+              <code>portlet-preferences.xml</code>
+              :
+            </para>
+            <informalexample>
+              <programlisting language="XML">
+&lt;! The number of files are uploaded --&gt;
+	&lt;preference&gt;
+		&lt;name&gt;uploadFileLimit&lt;/name&gt;
+		&lt;value&gt;3&lt;/value&gt;
+		&lt;read-only&gt;false&lt;/read-only&gt;
+	&lt;/preference&gt;
+&lt;! The size limit --&gt;
+	&lt;preference&gt;
+		&lt;name&gt;uploadFileSizeLimit&lt;/name&gt;
+		&lt;value&gt;300&lt;/value&gt;
+		&lt;read-only&gt;false&lt;/read-only&gt;
+	&lt;/preference&gt;
+&lt;! The unit limit --&gt;
+	&lt;preference&gt;
+		&lt;name&gt;uploadFileLimitUnit&lt;/name&gt;
+		&lt;value&gt;KB&lt;/value&gt;
+		&lt;read-only&gt;false&lt;/read-only&gt;
+	&lt;/preference&gt;
+</programlisting>
+            </informalexample>
+            <note>
+              <para>
+                The
+                <code>0</code>
+                value means the upload size is unlimited, and the value unit is set to megabytes.
+              </para>
+            </note>
+          </listitem>
+          <listitem>
+            <para>
+              Use the
+              <code>getUploadDataAsStream()</code>
+              method to get the uploaded data:
+            </para>
+            <informalexample>
+              <programlisting language="Java">
+UIUploadInput input = (UIUploadInput)uiForm.getUIInput("upload");
+InputStream[] inputStreams = input.getUploadDataAsStreams();
+...
+</programlisting>
+            </informalexample>
+            <para>The upload service stores a temporary file on the file system during the upload process. When the upload is finished, the service must be cleaned to:</para>
+            <itemizedlist>
+              <listitem>
+                <para>Delete the temporary file.</para>
+              </listitem>
+              <listitem>
+                <para>Delete the classes used for the upload.</para>
+              </listitem>
+            </itemizedlist>
+          </listitem>
+          <listitem>
+            <para>
+              Use the
+              <code>removeUploadResource(String uploadId)</code>
+              method defined in the upload service to purge the file:
+            </para>
+            <informalexample>
+              <programlisting language="Java">
+UploadService uploadService = uiForm.getApplicationComponent(UploadService.class);
+UIUploadInput uiChild = uiForm.getChild(UIFormUploadInput.class);
+for(String uploadId : uiChild.getUploadIds()) {
+    uploadService.removeUpload(uploadId);
+}
+</programlisting>
+            </informalexample>
+            <note>
+              <para>
+                Ensure the file is saved
+                <emphasis role="italics">before</emphasis>
+                the service is cleaned.
+              </para>
+            </note>
+          </listitem>
+        </orderedlist>
+      </section>
+</chapter>

Modified: epp/docs/branches/6.0/Reference_Guide/en-US/modules/PortalDevelopment.xml
===================================================================
--- epp/docs/branches/6.0/Reference_Guide/en-US/modules/PortalDevelopment.xml	2013-02-04 22:22:33 UTC (rev 9113)
+++ epp/docs/branches/6.0/Reference_Guide/en-US/modules/PortalDevelopment.xml	2013-02-04 23:31:31 UTC (rev 9114)
@@ -14,6 +14,7 @@
      <xi:include href="PortalDevelopment/InternationalizationConfiguration.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
      <xi:include href="PortalDevelopment/LocalizationConfiguration.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
      <xi:include href="PortalDevelopment/XMLResourceBundles.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+     <xi:include href="PortalDevelopment/UploadComponent.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
      <xi:include href="PortalDevelopment/RTLFramework.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
      <xi:include href="PortalDevelopment/JavascriptInterApplicationCommunication.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
      <!--      <xi:include href="PortalDevelopment/JavascriptConfiguration.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />      --> 



More information about the gatein-commits mailing list