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

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