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.

UsingVaadinInIBMDomino.asciidoc 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. ---
  2. title: Using Vaadin In IBM Domino
  3. order: 7
  4. layout: page
  5. ---
  6. [[using-vaadin-in-ibm-domino]]
  7. Using Vaadin In IBM Domino
  8. --------------------------
  9. Vaadin can be used as a UI technology in Domino. This page will contain
  10. the instruction how to setup the development environment and to get
  11. started with your first Vaadin app in Domino.
  12. The steps for setting up XPages SDK are:
  13. 1. Download the
  14. http://www.openntf.org/main.nsf/project.xsp?r=project/XPages%20SDK%20for%20Eclipse%20RCP/releases/0C60A1BFF5F40FD586257D8D005AA593[XPages
  15. SDK for Luna and above from OpenNTF]
  16. 2. In Eclipse, from the Help menu select *Install New Software….*
  17. 3. Select *Add…*, then choose *Archive…* and navigate to the zip file
  18. downloaded. +
  19. image:https://lh3.googleusercontent.com/PznhvZ1_SL6oJAm_J7BDsd0uBRHK7HDgCm6XJThdSRrPxDymwjYWOxbDpJ5Kt_5VIOIR-SP4Zl9KDAwCG0wzWni1iTwK8FUcmT8P_mYo4GxdtGjPZS4D8Y9pQus3dHM-kNeaRmfChg[Add XPages repository]
  20. 4. You will need to deselect *Group items by category*. Two features
  21. will show. The first includes sources, so select the second and click
  22. *Next*. +
  23. image:https://lh6.googleusercontent.com/PcTpwSQ-XpG-6c51FQ0W2upuK7XTNmawdi8vVgMb31pCBUg8Lt1oInKXT7r7o21Qjj_KJtie3yLxtPvGtCnltuNwGtj42ChuMEJBkqys8nt3KCmilFydpm6iFrme6Ro-FL4uZtUjkA[Select features]
  24. 5. Accept the terms and finish the dialog. You will be prompted to
  25. restart Eclipse to complete the install.
  26. 6. Select *Window* > *Preferences* (on Mac the location is *Eclipse* >
  27. *Preferences*). In the XPages SDK category tick *Automatically create
  28. JRE* and point to your local Notes and Domino installs. Then click
  29. *Apply*. +
  30. image:https://lh4.googleusercontent.com/22p8lT8-LrVTSKMDM0rpK2rFJT2EVfAuT62DyTYu6-x_eeddy6pEm1Io1haYlbGMwIE6PY8YRAUIEw0HQkXcHs6sNdnxkguXO4vv5VRKnoWUulDC6t46oDYI8Y9EjraTEV-dDHT6Wg[Select XPages SDK]
  31. 7. In the *Java* > *Installed JREs* category you should now have two
  32. additional options, “XPages Domino JRE” and “XPages Notes JRE”. Under
  33. *Plug-in Development* > *Target Platform* click *Add…*. Select the
  34. *Domino Install Target* template and complete. +
  35. image:https://lh5.googleusercontent.com/q0i66CSxHHvtQHXX4d-sq6AzElKUH_Lj-D9bg2awQL0Gn3WkcW_eTC7p_WBL94GUpB7ohEGw_i33Mk9K-q8wJ-2F5cguXimdrcCJxkELNLYC1FBzmDsx6FJo3-7wotvPdPGYVq_EeA[Configure target definition]
  36. 8. Apply this as the target platform. +
  37. image:https://lh6.googleusercontent.com/bguj0lMgODnG96vnU-RyBXCpz-FsodyAuvR6E-X3AsOoi4jC5iEilOtfssxk_Mwl3Ks1RPIbm6Pu6VzjmhOAnaL5c219wStTvw8cGKlG3pKSCVuSCcqHmHHpAxDHqK9c8TYT18siGA[Apply target definition]
  38. If you do not have a Domino server installed, there is an alternative
  39. approach. However, to test your OSGi plugin, you will need to create a
  40. Feature project, add the Plugin to that feature, then create an Update
  41. Site Project, add the feature to the update site, build and export. Then
  42. you will need to import that into an Update Site database on your
  43. server. This is the same process for creating and testing any other OSGi
  44. plugin on the server, such as XPages Extension Library.
  45. 1. Download the
  46. http://www.openntf.org/main.nsf/project.xsp?r=project/XPages%20SDK%20for%20Eclipse%20RCP/releases/0C60A1BFF5F40FD586257D8D005AA593[IBM
  47. Domino Update Site for Build Management from OpenNTF]. This is basically
  48. a zip file that contains features and plugins required for Maven and
  49. Tycho development in Eclipse, but also has all the dependencies required
  50. for Eclipse.
  51. 2. In Eclipse, go to *Window* > *Preferences* (on Mac the location is
  52. *Eclipse* > *Preferences*). Then go to *Plug-in Development* > *Target
  53. Platform*.
  54. 3. Edit the existing target platform configuration and in the dialog,
  55. click *Add…*, then *Directory*, then Next. Browse to and select the
  56. folder where you extracted the Update Site.> +
  57. image:https://lh5.googleusercontent.com/H2SiM2GdW9GYFzX_Az1Y7S_KAPnxYaGxwludqlqQoT3P1oVRDNxlC53uTt6SIrtQkPn42hr7yYqaJPK3hY9yF7BVeH8dPdwknzwLdeTIGgOXToWkKhy4smxg0hucyt3aWbmtjFpsgg[Add content]
  58. 4. The current release of Domino, 9.0.1, only supports Java 1.6. The
  59. next release, probably called Domino 9.0.2 and expected to ship first
  60. half 2016, is expected to include Java 1.8. But in the meantime, it’s
  61. best to set the JRE accordingly. In the preferences, go to *Java* >
  62. *Installed JREs* category.
  63. 5. *Add…*, *Standard VM*, then *Next* +
  64. image:https://lh6.googleusercontent.com/CGTOZTDGlIzgLNWn-1gTnrmhl7knp3SM2up9CX1cknk4Fyu5NfzQXjBDu2_yBz6gfq2HBppWH4gessWitIqUMOW793v_E7VekqUPJSAw0lVXj0inSusqi7gzjw6NjRsIDwJqvirjDA[Add JRE]
  65. 6. Click *Directory* and browse to your IBM Notes install’s “jvm”
  66. library. Give it an appropriate name and click *Finish*. Alternatively,
  67. if you don’t have IBM Notes installed on the development environment,
  68. download Java SE 6 SDK from Oracle. +
  69. image:https://lh5.googleusercontent.com/ipTTRFnUl_Ew0UE0X7XOaqqGcjEwUMAosAY6LDJ0_XZg8d7TyjsnRmDXDjGY3yrCOZ_54q9a23eqKZU0G__HwLKlglRxw5XeW2eDHvKPsgBpRu7YKcP46nKL_2KcCN4ljt1F3NAlFw[Configure JRE]
  70. [[setting-up-vaadin]]
  71. Setting up Vaadin
  72. ^^^^^^^^^^^^^^^^^
  73. Eclipse has a set of Vaadin plugins that can easily be installed to set
  74. up your environment.
  75. 1. *Select *Help* > *Eclipse Marketplace…*.*
  76. 2. Search for "Vaadin" amd install the**Vaadin Plugin for Eclipse** +
  77. image:https://lh4.googleusercontent.com/SpgGN3m6aFksfRJG47RVBg4qi5D7r9dhfaIUwHkm3A8TLfkF6M2farq2ZZf-zvjZakrNl1wALHHqGtiP6GNoVyIFHJs9Dpr9Tt3yqtWS6TwFMN1qsJ47o3T4UqU-G1SW0KCIbQGBnA[Select Vaadin plugin]
  78. 3. The options to install will include the *Vaadin Designer*, so leave
  79. all selected, confirm and accept the license. You will be prompted to
  80. restart Eclipse to complete the install.
  81. [[hello-world-example]]
  82. Hello World Example
  83. ^^^^^^^^^^^^^^^^^^^
  84. Now the development environment is set up, it’s time to create a Hello
  85. World application. But this one will not just print “Hello World” to the
  86. browser, instead it will add in the other key aspect, integrating with
  87. Domino. Maven is a useful tool for loading dependencies automatically,
  88. but will require the
  89. http://www.openntf.org/main.nsf/project.xsp?r=project/IBM%20Domino%20Update%20Site%20for%20Build%20Management[IBM
  90. Domino Update Site for Build Management] mentioned earlier. So at this
  91. point the approach will just create a simple non-Mavenized plugin.
  92. 1. In Eclipse, select *File* > *New* > *Plug-in Project* and give it a
  93. name. As an OSGi plugin, tell it to run with the OSGi framework
  94. “Equinox”.
  95. image:img/domino1.png[1]
  96. 2. Until the next release of Domino is out, the execution environment
  97. needs to be changed to Java 1.6. Then finish – the Eclipse perspective
  98. used for development is not significant at this stage.
  99. image:img/domino2.png[2]
  100. 3. The MANIFEST.MF will be opened and some additional configuration is
  101. required. The plugin should be set as a singleton on the Overview tab.
  102. image:img/domino3.png[3]
  103. 4. On the Dependencies tab some plugins and packages need loading for
  104. OSGi and Domino, as below.
  105. image:img/domino4.png[4]
  106. 5. Back on the Overview tab, click the Extension Points link and
  107. confirm you want to display the Extension and Extension Point pages.
  108. image:img/domino4.png[5]
  109. 6. On the Extensions tab, click *Add…* and choose
  110. `com.ibm.pvc.webcontainer.application`.
  111. image:img/domino6.png[6]
  112. 7. Set the contextRoot to “/helloVaadin”.
  113. image:img/domino7.png[7]
  114. 8. Right-click on *com.ibm.pvc.webcontainer.application* and select
  115. *New* > *contentLocation*. Set it to “WebContent”. These two steps can
  116. be done by manually typing the relevant XML onto the plugin.xml tab and
  117. I would recommend you loop at what the resulting XML is.
  118. image:img/domino8.png[8]
  119. 9. Next download the Vaadin jar files that will be needed from the
  120. https://vaadin.com/download#direct-download[Vaadin website]. The
  121. README.txt file outlines the steps required to add it to the project,
  122. but are repeated below.
  123. 10. Right-click the project and select *New* > *Folder* and call it
  124. WebContent/WEB-INF/lib.
  125. image:img/domino9.png[9]
  126. 11. Copy all jars to WebContent/WEB-INF/lib. Copy all jars in the lib
  127. folder to WebContent/WEB-INF/lib.
  128. 12. In the MANIFEST.MF, on the *Runtime* tab in the *Classpath* section,
  129. click *Add…* and add all the jar files added to WebContent/WEB-INF/lib.
  130. You must select the jars, not the folder. Then remember to move the “.”
  131. entry to the top of the list.
  132. image:img/domino10.png[10]
  133. 13. Right-click the WebContent/WEB-INF folder and select *New* > *File*.
  134. Call it web.xml.
  135. 14. Paste in the code below:
  136. +
  137. [source,xml]
  138. ....
  139. <?xml version="1.0" encoding="ISO-8859-1"?>
  140. <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
  141. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  142. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
  143. http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  144. <display-name>HelloVaadin</display-name>
  145.    <welcome-file-list>
  146.      <welcome-file>index.html</welcome-file>
  147.      <welcome-file>index.htm</welcome-file>
  148.      <welcome-file>index.jsp</welcome-file>
  149.      <welcome-file>default.html</welcome-file>
  150.      <welcome-file>default.htm</welcome-file>
  151.      <welcome-file>default.jsp</welcome-file>
  152.    </welcome-file-list>
  153.    <context-param>
  154.        <description>Vaadin production mode</description>
  155.        <param-name>productionMode</param-name>
  156.        <param-value>false</param-value>
  157.    </context-param>
  158.    
  159.    <servlet>
  160.        <servlet-name>HelloVaadinServlet</servlet-name>
  161.        <servlet-class>com.vaadin.server.VaadinServlet</servlet-class>
  162.        <init-param>
  163.            <param-name>UI</param-name>
  164.            <param-value>com.paulwithers.hellovaadin.HelloVaadinUI</param-value>
  165.        </init-param>
  166.    </servlet>
  167.    <servlet-mapping>
  168.        <servlet-name>HelloVaadinServlet</servlet-name>
  169.        <url-pattern>/*</url-pattern>
  170.    </servlet-mapping>
  171. </web-app>
  172. ....
  173. +
  174. This first block gives a list of default URL extensions accepted for
  175. mapping and tells the application to run in development mode. The
  176. <servlet> block gives the servlet name and points to a class we will
  177. create later which will initialise the NotesThread required for talking
  178. to Domino. The initParam points to a class we will create later that
  179. will be the entry point into the application.
  180. 15. Right-click com.paulwithers.hellovaadin and select *New* > *Vaadin
  181. Design*. You will need an evaluation or full license for Vaadin
  182. Designer. To get the trial license, log into the vaadin.com website and
  183. go to https://vaadin.com/designer#license-modal[https://vaadin.com/designer#license-modal.]
  184. 16. Call the design page “WelcomeDesign” and use the *Vertical Layout*
  185. template. Finish and confirm to switch to the Vaadin perspective.
  186. 17. Drag and drop a new Label onto the page (components are displayed
  187. alphabetically). In the Properties view set the name to “label1”. Click
  188. the ellipsis button next to *StyleName*. Select “LABEL_H2” and click
  189. *Add ->*, then OK. Change *ComponentAlignment* to “TOP_CENTER”. Save and
  190. close.
  191. 18. Switch back to the Plug-in Development perspective. This is better
  192. suited to plugin development. Note the “WelcomeDesign.html” and
  193. “WelcomeDesign.java” files. Review WelcomeDesign.java.
  194. 19. Right-click on com.paulwithers.hellovaadin and select *New* >
  195. *Class*. Call it WelcomeView and set the superclass as WelcomeDesign.
  196. image:img/domino12.png[12]
  197. 20. Add the following code to the class to extend the auto-generated class and to compute the value of label1.
  198. +
  199. [source,java]
  200. ....
  201. import com.ibm.domino.osgi.core.context.ContextInfo;
  202. public class WelcomeView extends WelcomeDesign {
  203.     private static final long serialVersionUID = 1L;
  204.     public WelcomeView() {
  205.         super();
  206.         try {
  207.             label1.setValue("Welcome " +
  208. ContextInfo.getUserSession().getEffectiveUserName());
  209.         } catch (final Exception e) {
  210.             // TODO: handle exception
  211.         }
  212.     }
  213. }
  214. ....
  215. 21. You may get an error that the method Session.getEffectiveUserName()
  216. is not API. That can be fixed by amending the Java compiler settings, by
  217. changing the setting for forbidden reference to “Warning”.
  218. image:img/domino13.png[13]
  219. 22. Right-click on *src/com.paulwithers.hellovaadin* and select *New* >
  220. *Class*. Class it “HelloVaadinUI” and set the superclass as
  221. “com.vaadin.ui.UI”.
  222. image:img/domino14.png[14]
  223. 23. Add the following code to the class:
  224. +
  225. [source,java]
  226. ....
  227. import com.vaadin.server.VaadinRequest;
  228. import com.vaadin.ui.UI;
  229. public class HelloVaadinUI extends UI {
  230.     @Override
  231.     protected void init(VaadinRequest request) {
  232.         final WelcomeView welcome = new WelcomeView();
  233.         setContent(welcome);
  234.     }
  235. }
  236. ....
  237. This creates an instance of the WelcomeView class just created and loads
  238. it to the page.
  239. 24. On the *Build* tab ensure META-INF, WebContent, plugin.xml, src are
  240. all ticked for Binary Build.
  241. 25. On the Overview tab, launch the *Organize Manifests Wizard* and
  242. complete.
  243. image:img/domino15.png[15]
  244. 26. Select *File* > *New* > *Feature Project*. Call it
  245. com.paulwithers.helloVaadinFeature.
  246. image:img/domino16.png[16]
  247. 27. Click Next and initialize from the com.paulwithers.helloVaadin
  248. plugin.
  249. 28. Select *File* > *New* > *Update Site Project*. Call it
  250. com.paulwithers.helloVaadinUpdate and click Finish. Click *Add Feature…*
  251. and select com.paulwithers.helloVaadinFeature. Click *Build All*.
  252. 29. Right-click com.paulwithers.helloVaadinUpdate and click *Export…*.
  253. Choose *General > File System*. You only need to select the site.xml.
  254. Export to an appropriate location.
  255. image:img/domino17.png[17]
  256. 30. In an Update Site database on the relevant server, import the update
  257. site by pointing to the site.xml.
  258. image:img/domino18.png[18]
  259. +
  260. As with any OSGi plugin, you will need to issue “restart task http”
  261. command to the server for the plugin to be available.
  262. 31. If you browse to the “helloVaadin” URL on the server (corresponding
  263. to the contextRoot in the plugin.xml), you should now see “Hello
  264. Anonymous” message.
  265. image:img/domino19.png[19]
  266. If you log in or prefix the contextRoot with the filepath of a database
  267. that does not allow anonymous access, you will see a welcome message for
  268. the current logged in user.
  269. image:img/domino20.png[20]