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-deployment.asciidoc 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. ---
  2. title: Deploying to a Portal
  3. order: 5
  4. layout: page
  5. ---
  6. [[portal.deployment]]
  7. = Deploying to a Portal
  8. For OSGi portlets in Liferay 7, see
  9. <<portal-osgi#portal.osgi.portlet,"Publishing a Portlet With OSGi">>.
  10. The text below applies mostly to non-OSGi portlets.
  11. To deploy a portlet WAR in a portal, you need to provide a
  12. [filename]#portlet.xml# descriptor specified in the Java Portlet API 2.0
  13. standard (JSR-286). In addition, you may need to include possible portal vendor
  14. specific deployment descriptors. The ones required by Liferay are described
  15. below.
  16. Deploying a Vaadin UI as a portlet is essentially just as easy as deploying a
  17. regular application to an application server. You do not need to make any
  18. changes to the UI itself, but only the following:
  19. [options="compact"]
  20. * Application packaged as a WAR
  21. ** [filename]#WEB-INF/portlet.xml# descriptor
  22. ** [filename]#WEB-INF/liferay-portlet.xml# descriptor for Liferay
  23. ** [filename]#WEB-INF/liferay-display.xml# descriptor for Liferay
  24. ** [filename]#WEB-INF/liferay-plugin-package.properties# for Liferay
  25. * Widget set installed to portal (optional)
  26. * Themes installed to portal (optional)
  27. * Vaadin libraries installed to portal (optional)
  28. * Portal configuration settings (optional)
  29. Installing the widget set and themes to the portal is required for running two or more Vaadin portlets simultaneously in a single portal page.
  30. As this situation occurs quite easily, we recommend installing them in any case.
  31. Instructions for Liferay are given in <<portal-liferay#portal.liferay,"Developing Vaadin Portlets for Liferay">> and the procedure is similar for other portals.
  32. In addition to the Vaadin libraries, you will need to have the
  33. [filename]#portlet.jar# in your project classpath. However, notice that you must
  34. __not__ put the [filename]#portlet.jar# in the same [filename]#WEB-INF/lib#
  35. directory as the Vaadin JAR or otherwise include it in the WAR to be deployed,
  36. because it would create a conflict with the internal portlet library of the
  37. portal. The conflict would cause errors such as "
  38. [literal]#++ClassCastException: ...VaadinPortlet cannot be cast to
  39. javax.portlet.Portlet++#".
  40. [[portal.deployment.descriptor]]
  41. == Portlet Deployment Descriptor
  42. The portlet WAR must include a portlet descriptor located at [filename]#WEB-INF/portlet.xml#.
  43. A portlet definition includes the portlet name, mapping to a servlet, modes supported by the portlet, and other configuration.
  44. Below is an example of a simple portlet definition in [filename]#portlet.xml# descriptor.
  45. [subs="verbatim,replacements,quotes"]
  46. ----
  47. &lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  48. &lt;portlet-app
  49. xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
  50. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  51. version="2.0"
  52. xsi:schemaLocation=
  53. "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd
  54. http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"&gt;
  55. &lt;portlet&gt;
  56. &lt;portlet-name&gt;[replaceable]##Portlet Example portlet##&lt;/portlet-name&gt;
  57. &lt;display-name&gt;[replaceable]##Vaadin Portlet Example##&lt;/display-name&gt;
  58. &lt;!-- Map portlet to a servlet. --&gt;
  59. &lt;portlet-class&gt;
  60. com.vaadin.server.VaadinPortlet
  61. &lt;/portlet-class&gt;
  62. &lt;init-param&gt;
  63. &lt;name&gt;UI&lt;/name&gt;
  64. &lt;!-- The application class with package name. --&gt;
  65. &lt;value&gt;[replaceable]##com.example.myportlet.MyportletUI##&lt;/value&gt;
  66. &lt;/init-param&gt;
  67. &lt;!-- Supported portlet modes and content types. --&gt;
  68. &lt;supports&gt;
  69. &lt;mime-type&gt;text/html&lt;/mime-type&gt;
  70. &lt;portlet-mode&gt;view&lt;/portlet-mode&gt;
  71. &lt;portlet-mode&gt;edit&lt;/portlet-mode&gt;
  72. &lt;portlet-mode&gt;help&lt;/portlet-mode&gt;
  73. &lt;/supports&gt;
  74. &lt;!-- Not always required but Liferay requires these. --&gt;
  75. &lt;portlet-info&gt;
  76. &lt;title&gt;[replaceable]##Vaadin Portlet Example##&lt;/title&gt;
  77. &lt;short-title&gt;[replaceable]##Portlet Example##&lt;/short-title&gt;
  78. &lt;/portlet-info&gt;
  79. &lt;/portlet&gt;
  80. &lt;/portlet-app&gt;
  81. ----
  82. The mode definitions enable the corresponding portlet controls in the portal.
  83. The portlet controls allow changing the mode of the portlet, as described later.
  84. [[portal.deployment.liferay]]
  85. == Liferay Portlet Descriptor
  86. ((("Liferay", "portlet descriptor", id="term.portal.liferay.descriptor.liferay-portlet.liferay", range="startofrange")))
  87. Liferay requires a special [filename]#liferay-portlet.xml# descriptor file that
  88. defines Liferay-specific parameters. Especially, Vaadin portlets must be defined
  89. as " __instanceable__", but not " __ajaxable__".
  90. Below is an example descriptor for the earlier portlet example:
  91. [subs="normal"]
  92. ----
  93. &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  94. &lt;!DOCTYPE liferay-portlet-app PUBLIC
  95. "-//Liferay//DTD Portlet Application 4.3.0//EN"
  96. "http://www.liferay.com/dtd/liferay-portlet-app_4_3_0.dtd"&gt;
  97. &lt;liferay-portlet-app&gt;
  98. &lt;portlet&gt;
  99. &lt;!-- Matches definition in portlet.xml. --&gt;
  100. &lt;!-- Note: Must not be the same as servlet name. --&gt;
  101. &lt;portlet-name&gt;[replaceable]##Portlet Example portlet##&lt;/portlet-name&gt;
  102. &lt;instanceable&gt;true&lt;/instanceable&gt;
  103. &lt;ajaxable&gt;false&lt;/ajaxable&gt;
  104. &lt;/portlet&gt;
  105. &lt;/liferay-portlet-app&gt;
  106. ----
  107. See Liferay documentation for further details on the
  108. [filename]#liferay-portlet.xml# deployment descriptor.
  109. (((range="endofrange", startref="term.portal.liferay.descriptor.liferay-portlet.liferay")))
  110. [[portal.deployment.liferay-display]]
  111. == Liferay Display Descriptor
  112. ((("[filename]#liferay-display.xml#", id="term.portal.liferay.descriptor.liferay-display", range="startofrange")))
  113. ((("Liferay", "display descriptor", id="term.portal.liferay.descriptor.liferay-display.liferay", range="startofrange")))
  114. The [filename]#WEB-INF/liferay-display.xml# file defines the portlet category
  115. under which portlets are located in the [guilabel]#Add Application# window in
  116. Liferay. Without this definition, portlets will be organized under the
  117. "Undefined" category.
  118. The following display configuration, which is included in the demo WAR, puts the
  119. Vaadin portlets under the "Vaadin" category, as shown in
  120. <<figure.portal.liferay.descriptor.display>>.
  121. ----
  122. <?xml version="1.0"?>
  123. <!DOCTYPE display PUBLIC
  124. "-//Liferay//DTD Display 4.0.0//EN"
  125. "http://www.liferay.com/dtd/liferay-display_4_0_0.dtd">
  126. <display>
  127. <category name="Vaadin">
  128. <portlet id="Portlet Example portlet" />
  129. </category>
  130. </display>
  131. ----
  132. [[figure.portal.liferay.descriptor.display]]
  133. .Portlet Categories in Add Application Window
  134. image::img/liferay-display-hi.png[width=60%]
  135. See Liferay documentation for further details on how to configure the categories
  136. in the [filename]#liferay-display.xml# deployment descriptor.
  137. (((range="endofrange", startref="term.portal.liferay.descriptor.liferay-display")))
  138. (((range="endofrange", startref="term.portal.liferay.descriptor.liferay-display.liferay")))
  139. [[portal.deployment.liferay-plugin]]
  140. == Liferay Plugin Package Properties
  141. ((("[filename]#liferay-plugin-package.xml#", id="term.portal.liferay.descriptor.liferay-plugin", range="startofrange")))
  142. ((("Liferay", "plugin properties", id="term.portal.liferay.descriptor.liferay-plugin.liferay", range="startofrange")))
  143. The [filename]#liferay-plugin-package.properties# file defines a number of
  144. settings for the portlet, most importantly the Vaadin JAR to be used.
  145. [subs="normal"]
  146. ----
  147. name=[replaceable]##Portlet Example portlet##
  148. short-description=[replaceable]##myportlet##
  149. module-group-id=[replaceable]##Vaadin##
  150. module-incremental-version=1
  151. #change-log=
  152. #page-uri=
  153. #author=
  154. license=Proprietary
  155. portal-dependency-jars=\
  156. [replaceable]##vaadin.jar##
  157. ----
  158. [parameter]#name#:: The plugin name must match the portlet name.
  159. [parameter]#short-description#:: A short description of the plugin. This is by default the project name.
  160. [parameter]#module-group-id#:: The application group, same as the category id defined in
  161. [filename]#liferay-display.xml#.
  162. [parameter]#license#:: The plugin license type; "proprietary" by default.
  163. [parameter]#portal-dependency-jars#:: The JAR libraries on which this portlet depends. This should have value
  164. [filename]#vaadin.jar#, unless you need to use a specific version. The JAR must
  165. be installed in the portal, for example, in Liferay bundled with Tomcat to
  166. [filename]#tomcat-x.x.x/webapps/ROOT/WEB-INF/lib/vaadin.jar#.
  167. (((range="endofrange", startref="term.portal.liferay.descriptor.liferay-plugin")))
  168. (((range="endofrange", startref="term.portal.liferay.descriptor.liferay-plugin.liferay")))
  169. [[portal.deployment.widgetset]]
  170. == Using a Single Widget Set
  171. If you have just one Vaadin application that you ever need to run in your
  172. portal, you can just deploy the WAR as described above and that's it. However,
  173. if you have multiple applications, especially ones that use different custom
  174. widget sets, you run into problems, because a portal window can load only a
  175. single Vaadin widget set at a time. You can solve this problem by combining all
  176. the different widget sets in your different applications into a single widget
  177. set using inheritance or composition.
  178. For example, if using the default widget set for portlets, you should have the
  179. following for all portlets so that they will all use the same widget set:
  180. ----
  181. <portlet>
  182. ...
  183. <!-- Use the portal default widget set for all portal demos. -->
  184. <init-param>
  185. <name>widgetset</name>
  186. <value>com.vaadin.portal.PortalDefaultWidgetSet</value>
  187. </init-param>
  188. ...
  189. ----
  190. The [classname]#PortalDefaultWidgetSet# extends [classname]#SamplerWidgetSet#,
  191. which extends the [classname]#DefaultWidgetSet#. The
  192. [classname]#DefaultWidgetSet# is therefore essentially a subset of
  193. [classname]#PortalDefaultWidgetSet#, which contains also the widgets required by
  194. the Sampler demo. Other applications that would otherwise require only the
  195. regular [classname]#DefaultWidgetSet#, and do not define their own widgets, can
  196. just as well use the larger set, making them compatible with the demos. The
  197. [classname]#PortalDefaultWidgetSet# will also be the default Vaadin widgetset
  198. bundled in Liferay 5.3 and later.
  199. If your portlets are contained in multiple WARs, which can happen quite
  200. typically, you need to install the widget set and theme portal-wide so that all
  201. the portlets can use them. See
  202. <<portal-liferay#portal.liferay,"Developing
  203. Vaadin Portlets for Liferay">> on configuring the widget sets in the portal
  204. itself.
  205. [[portal.deployment.war]]
  206. == Building the WAR Package
  207. To deploy the portlet, you need to build a WAR package. For production
  208. deployment, you probably want to either use Maven or an Ant script to build the
  209. package. In Eclipse, you can right-click on the project and select "Export >
  210. WAR". Choose a name for the package and a target. If you have installed Vaadin
  211. in the portal as described in
  212. <<portal-liferay#portal.liferay,"Developing
  213. Vaadin Portlets for Liferay">>, you should exclude all the Vaadin libraries, as
  214. well as widget set and themes from the WAR.
  215. [[portal.deployment.deploy]]
  216. == Deploying the WAR Package
  217. How you actually deploy a WAR package depends on the portal. In Liferay, you
  218. simply drop it to the [filename]#deploy# subdirectory under the Liferay
  219. installation directory. The deployment depends on the application server under
  220. which Liferay runs; for example, if you use Liferay bundled with Tomcat, you
  221. will find the extracted package in the [filename]#webapps# directory under the
  222. Tomcat installation directory included in Liferay.