You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

portal-liferay.asciidoc 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. ---
  2. title: Developing Vaadin Portlets for Liferay
  3. order: 3
  4. layout: page
  5. ---
  6. [[portal.liferay]]
  7. = Developing Vaadin Portlets for Liferay
  8. A Vaadin portlet requires resources such as the server-side Vaadin libraries, a
  9. theme, and a widget set. You have two basic ways to deploy these: either
  10. globally in Liferay, so that the resources are shared between all Vaadin
  11. portlets, or as self-contained WARs, where each portlet carries their own
  12. resources.
  13. The self-contained way is easier and more flexible to start with, as the
  14. different portlets may have different versions of the resources. Currently, the
  15. latest Maven archetypes support the self-contained portlets, while with portlets
  16. created with the Vaadin Plugin for Eclipse only support globally deployed
  17. resources.
  18. Using shared resources is more efficient when you have multiple Vaadin portlets
  19. on the same page, as they can share the common resources. However, they must use
  20. exactly same Vaadin version. This is recommended for production environments,
  21. where you can even serve the theme and widget set from a front-end server. You
  22. can install the shared resources as described in <<portal.liferay.install>>.
  23. At the time of writing, the latest Liferay release 6.2 is bundled with a version
  24. of Vaadin release 6. If you want to use Vaadin 7 portlets with shared resources,
  25. you first need to remove the old ones as described in <<portal.liferay.remove>>.
  26. [[portal.liferay.profile]]
  27. == Defining Liferay Profile for Maven
  28. When creating a Liferay portlet project with a Maven archetype or the Liferay
  29. IDE, you need to define a Liferay profile. With the Liferay IDE, you can create
  30. it when you create the project, as described in <<portal.liferay.ide>>, but for
  31. creating a project from the Maven archetype, you need to define in manually.
  32. [[portal.liferay.profile.settings]]
  33. === Defining Profile in [filename]#settings.xml#
  34. Liferay profile can be defined either in the user or in the global
  35. [filename]#settings.xml# file for Maven. The global settings file is located in
  36. [filename]#${MAVEN_HOME}/conf/settings.xml# and the user settings file in
  37. [filename]#${USER_HOME}/.m2/settings.xml#. To create a user settings file, copy
  38. at least the relevant headers and root element from the global settings file.
  39. [subs="normal"]
  40. ----
  41. ...
  42. &lt;profile&gt;
  43. &lt;id&gt;**liferay**&lt;/id&gt;
  44. &lt;properties&gt;
  45. &lt;liferayinstall&gt;**/opt/liferay-portal-6.2-ce-ga2**
  46. &lt;/liferayinstall&gt;
  47. &lt;plugin.type&gt;portlet&lt;/plugin.type&gt;
  48. &lt;liferay.version&gt;**6.2.1**&lt;/liferay.version&gt;
  49. &lt;liferay.maven.plugin.version&gt;**6.2.1**
  50. &lt;/liferay.maven.plugin.version&gt;
  51. &lt;liferay.auto.deploy.dir&gt;${liferayinstall}/**deploy**
  52. &lt;/liferay.auto.deploy.dir&gt;
  53. &lt;!-- Application server version - here for Tomcat --&gt;
  54. &lt;liferay.tomcat.version&gt;**7.0.42**&lt;/liferay.tomcat.version&gt;
  55. &lt;liferay.tomcat.dir&gt;
  56. ${liferayinstall}/tomcat-${liferay.tomcat.version}
  57. &lt;/liferay.tomcat.dir&gt;
  58. &lt;liferay.app.server.deploy.dir&gt;**${liferay.tomcat.dir}/webapps**
  59. &lt;/liferay.app.server.deploy.dir&gt;
  60. &lt;liferay.app.server.lib.global.dir&gt;**${liferay.tomcat.dir}/lib/ext**
  61. &lt;/liferay.app.server.lib.global.dir&gt;
  62. &lt;liferay.app.server.portal.dir&gt;**${liferay.tomcat.dir}/webapps/ROOT**
  63. &lt;/liferay.app.server.portal.dir&gt;
  64. &lt;/properties&gt;
  65. &lt;/profile&gt;
  66. ----
  67. The parameters are as follows:
  68. liferayinstall:: Full (absolute) path to the Liferay installation directory.
  69. liferay.version:: Liferay version by the Maven version numbering scheme. The first two (major and minor) numbers are same as in the installation package. The third (maintenance) number starts from 0 with first GA (general availability) release.
  70. liferay.maven.plugin.version:: This is usually the same as the Liferay version.
  71. liferay.auto.deploy.dir:: The Liferay auto-deployment directory. It is by default [filename]#deploy# under the Liferay installation path.
  72. liferay.tomcat.version(optional):: If using Tomcat, its version number.
  73. liferay.tomcat.dir:: Full (absolute) path to Tomcat installation directory. For Tomcat bundled with Liferay, this is under the Liferay installation directory.
  74. liferay.app.server.deploy.dir:: Directory where portlets are deployed in the application server used for Liferay. This depends on the server - for Tomcat it is the [filename]#webapps# directory under the Tomcat installation directory.
  75. liferay.app.server.lib.global.dir:: Library path where libraries globally accessible in the application server should be installed.
  76. liferay.app.server.portal.dir:: Deployment directory for static resources served by the application server, under the root path of the server.
  77. If you modify the settings after the project is created, you need to touch the
  78. POM file in the project to have the settings reloaded.
  79. [[portal.liferay.profile.properties]]
  80. === Activating the Maven Profile
  81. The Maven 2 Plugin for Eclipse (m2e) must know which Maven profiles you use in a
  82. project. This is configured in the [menuchoice]#Maven# section of the project
  83. properties. In the [guilabel]#Active Maven Profiles# field, enter the profile ID
  84. defined in the [filename]#settings.xml# file, as illustrated in
  85. <<figure.portal.liferay.profile.properties>>.
  86. [[figure.portal.liferay.profile.properties]]
  87. .Activating Maven Liferay Profile
  88. image::img/liferay-maven-profile.png[]
  89. [[portal.liferay.project]]
  90. == Creating a Portlet Project with Maven
  91. Creation of Vaadin a Maven project is described in
  92. <<dummy/../../../framework/getting-started/getting-started-maven#getting-started.maven,"Using
  93. Vaadin with Maven">>. For a Liferay project, you should use the
  94. [literal]#++vaadin-archetype-liferay-portlet++#.
  95. [[portal.liferay.project.archetype-parameters]]
  96. === Archetype Parameters
  97. The archetype has a number of parameters. If you use Maven Plugin for Eclipse
  98. (m2e) to create the project, you get to enter the parameters after selecting the
  99. archetype, as shown in <<figure.portal.liferay.project.archetype-parameters>>.
  100. Minimally, you just need to enter the artifact ID. To activate the Maven profile
  101. created as described earlier in <<portal.liferay.profile>>, you need to specify
  102. the profile in the [guilabel]#Profiles# field under the [guilabel]#Advanced#
  103. section.
  104. [[figure.portal.liferay.project.archetype-parameters]]
  105. .Liferay Project Archetype Parameters
  106. image::img/liferay-maven-project.png[]
  107. The other parameters are the following:
  108. vaadinVersion:: Vaadin release version for the Maven dependency.
  109. uiClassName:: Class name of the UI class stub to be created.
  110. theme:: Theme to use. You can use either a project theme, which must be compiled before deployment, or use one of the default themes.
  111. portletTitle:: Title shown in the portlet title bar.
  112. portletShortTitle:: Title shown in contexts where a shorter title is preferred.
  113. portletKeywords:: Keywords for finding the portlet in Liferay.
  114. portletDescription:: A description of the portlet.
  115. portletName:: Identifier for the portlet, used for identifying it in the configuration files.
  116. portletDisplayName:: Name of the portlet for contexts where it is displayed.
  117. [[portal.liferay.ide]]
  118. == Creating a Portlet Project in Liferay IDE
  119. Liferay IDE, which you install in Eclipse as plugins just like the Vaadin
  120. plugin, enables a development environment for Liferay portlets. Liferay IDE
  121. allows integrated deployment of portlets to Liferay, just like you would deploy
  122. servlets to a server in Eclipse. The project creation wizard supports creation
  123. of Vaadin portlets.
  124. Loading widget sets, themes, and the Vaadin JAR from a portlet is possible as
  125. long as you have a single portlet, but causes a problem if you have multiple
  126. portlets. To solve this, Vaadin portlets need to use a globally installed widget
  127. set, theme, and Vaadin libraries.
  128. __Liferay 6.2, which is the latest Liferay version at the time of publication of
  129. this book, comes bundled with an older Vaadin 6 version. If you want to use
  130. Vaadin 7, you need to remove the bundled version and install the newer one
  131. manually as described in this chapter.__
  132. In these instructions, we assume that you use Liferay bundled with Apache
  133. Tomcat, although you can use almost any other application server with Liferay
  134. just as well. The Tomcat installation is included in the Liferay installation
  135. package, under the [filename]#tomcat-x.x.x# directory.
  136. [[portal.liferay.remove]]
  137. == Removing the Bundled Installation
  138. Before installing a new Vaadin version, you need to remove the version bundled
  139. with Liferay. You need to remove the Vaadin library JAR from the library
  140. directory of the portal and the [filename]#VAADIN# directory from under the root
  141. context. For example, with Liferay bundled with Tomcat, they are usually located
  142. as follows:
  143. * [filename]#tomcat-x.x.x/webapps/ROOT/html/VAADIN#
  144. * [filename]#tomcat-x.x.x/webapps/ROOT/WEB-INF/lib/vaadin.jar#
  145. [[portal.liferay.install]]
  146. == Installing Vaadin Resources
  147. To use common resources needed by multiple Vaadin portlets, you can install them
  148. globally as shared resources as described in the following.
  149. If you are installing Vaadin in a Liferay version that comes bundled with an
  150. older version of Vaadin, you first need to remove the resources as described in
  151. <<portal.liferay.remove>>.
  152. In the following, we assume that you use only the built-in "reindeer" theme in
  153. Vaadin and the default widget set.
  154. . Get the Vaadin installation package from the Vaadin download page
  155. . Extract the following Vaadin JARs from the installation package: [filename]#vaadin-server.jar# and [filename]#vaadin-shared.jar#, as well as the [filename]#vaadin-shared-deps.jar# and [filename]#jsoup.jar# dependencies from the [filename]#lib# folder
  156. . Rename the JAR files as they were listed above, without the version number
  157. . Put the libraries in [filename]#tomcat-x.x.x/webapps/ROOT/WEB-INF/lib/#
  158. . Extract the [filename]#VAADIN# folders from [filename]#vaadin-server.jar#,
  159. [filename]#vaadin-themes.jar#, and [filename]#vaadin-client-compiled.jar# and
  160. copy their contents to [filename]#tomcat-x.x.x/webapps/ROOT/html/VAADIN#.
  161. +
  162. [subs="normal"]
  163. ----
  164. [prompt]#$# [command]#cd# tomcat-x.x.x/webapps/ROOT/html
  165. ----
  166. +
  167. [subs="normal"]
  168. ----
  169. [prompt]#$# [command]#unzip# path-to/vaadin-server-7.1.0.jar 'VAADIN/*'
  170. ----
  171. +
  172. [subs="normal"]
  173. ----
  174. [prompt]#$# [command]#unzip# path-to/vaadin-themes-7.1.0.jar 'VAADIN/*'
  175. ----
  176. +
  177. [subs="normal"]
  178. ----
  179. [prompt]#$# [command]#unzip# path-to/vaadin-client-compiled-7.1.0.jar 'VAADIN/*'
  180. ----
  181. You need to define the widget set, the theme, and the JAR in the
  182. [filename]#portal-ext.properties# configuration file for Liferay, as described
  183. earlier. The file should normally be placed in the Liferay installation
  184. directory. See Liferay documentation for details on the configuration file.
  185. Below is an example of a [filename]#portal-ext.properties# file:
  186. ----
  187. # Path under which the VAADIN directory is located.
  188. # (/html is the default so it is not needed.)
  189. # vaadin.resources.path=/html
  190. # Portal-wide widget set
  191. vaadin.widgetset=com.vaadin.server.DefaultWidgetSet
  192. # Theme to use
  193. # This is the default theme if nothing is specified
  194. vaadin.theme=reindeer
  195. ----
  196. The allowed parameters are:
  197. [parameter]#vaadin.resources.path#:: Specifies the resource root path under the portal context. This is
  198. [filename]#/html# by default. Its actual location depends on the portal and the
  199. application server; in Liferay with Tomcat it would be located at
  200. [filename]#webapps/ROOT/html# under the Tomcat installation directory.
  201. [parameter]#vaadin.widgetset#:: The widget set class to use. Give the full path to the class name in the dot
  202. notation. If the parameter is not given, the default widget set is used.
  203. [parameter]#vaadin.theme#:: Name of the theme to use. If the parameter is not given, the default theme is
  204. used, which is [literal]#++reindeer++#.
  205. You will need to restart Liferay after creating or modifying the
  206. [filename]#portal-ext.properties# file.