{"id":1889,"date":"2015-01-24T22:07:18","date_gmt":"2015-01-24T20:07:18","guid":{"rendered":"http:\/\/hasselba.ch\/blog\/?p=1889"},"modified":"2015-01-26T21:57:38","modified_gmt":"2015-01-26T19:57:38","slug":"howto-vaadin-on-domino-2","status":"publish","type":"post","link":"https:\/\/hasselba.ch\/blog\/?p=1889","title":{"rendered":"HowTo: Vaadin on Domino (2)"},"content":{"rendered":"<p>When running your own servlet, you eventually want to access the Domino environment. To do this, some changes has to be made to <a title=\"HowTo: Vaadin on Domino\" href=\"https:\/\/hasselba.ch\/blog\/?p=1891\">the HelloVaadin plug-in<\/a>.<\/p>\n<p>1. Open the &#8222;<em>MANFIFEST.MF<\/em>&#8220; and open the &#8222;<em>Dependencies<\/em>&#8220; tab<\/p>\n<p>2. Add the plug-in &#8222;<em>com.ibm.osgi.domino.core<\/em>&#8220; to the list of required plug-ins<\/p>\n<p><a href=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2015\/01\/01-Dependencies-Add-OSGi-Plugin-00.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1953\" src=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2015\/01\/01-Dependencies-Add-OSGi-Plugin-00-276x300.png\" alt=\"01 - Dependencies - Add OSGi Plugin 00\" width=\"276\" height=\"300\" srcset=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2015\/01\/01-Dependencies-Add-OSGi-Plugin-00-276x300.png 276w, https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2015\/01\/01-Dependencies-Add-OSGi-Plugin-00.png 647w\" sizes=\"auto, (max-width: 276px) 100vw, 276px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2015\/01\/01-Dependencies-Add-OSGi-Plugin.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1951\" src=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2015\/01\/01-Dependencies-Add-OSGi-Plugin-300x250.png\" alt=\"01 - Dependencies - Add OSGi Plugin\" width=\"300\" height=\"250\" srcset=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2015\/01\/01-Dependencies-Add-OSGi-Plugin-300x250.png 300w, https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2015\/01\/01-Dependencies-Add-OSGi-Plugin.png 605w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2015\/01\/01-Dependencies-Add-OSGi-Plugin-02.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1952\" src=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2015\/01\/01-Dependencies-Add-OSGi-Plugin-02-300x144.png\" alt=\"01 - Dependencies - Add OSGi Plugin 02\" width=\"300\" height=\"144\" srcset=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2015\/01\/01-Dependencies-Add-OSGi-Plugin-02-300x144.png 300w, https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2015\/01\/01-Dependencies-Add-OSGi-Plugin-02.png 466w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Save the &#8222;<em>MANIFEST.MF<\/em>&#8220;<\/p>\n<p>3. Now we can use &#8222;<em>com.ibm.domino.osgi.core.context.ContextInfo<\/em>&#8220; to access the Domino environment in <em>HelloVaadinUI<\/em><\/p>\n<pre><code>package ch.hasselba.vaadin;\r\n\r\nimport lotus.domino.Database;\r\nimport lotus.domino.NotesException;\r\nimport lotus.domino.Session;\r\nimport com.vaadin.server.VaadinRequest;\r\nimport com.vaadin.server.VaadinServlet;\r\nimport com.vaadin.shared.ui.label.ContentMode;\r\nimport com.vaadin.ui.Label;\r\nimport com.vaadin.ui.UI; \r\nimport com.vaadin.ui.VerticalLayout;\r\nimport com.ibm.domino.osgi.core.context.ContextInfo;\r\n\r\n@SuppressWarnings(\"serial\")\r\npublic class HelloVaadinUI extends UI {\r\n\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0 public static class Servlet extends VaadinServlet {\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0 @Override\r\n\u00a0\u00a0\u00a0 protected void init(VaadinRequest request) {\r\n\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 VerticalLayout layout = new VerticalLayout();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 setContent(layout);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 layout.setSizeFull();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 String dbPath = \"\";\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 String userName = \"\";\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 String queryString = \"\";\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 try {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\/\/ get the current database\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Database db = ContextInfo.getUserDatabase();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0if( db != null )\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0dbPath = db.getFilePath();\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\/\/ get the current session\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Session session = ContextInfo.getUserSession();\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0if( session != null )\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0userName = session.getEffectiveUserName();\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\/\/ get the query string\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0queryString = ContextInfo.getServerVariable(\"QUERY_STRING\");\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0} catch (NotesException e) {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0e.printStackTrace();\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0}\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Label label = new Label();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 label.setValue(\"&lt;h1&gt;Hello \" + userName + \"!&lt;\/h1&gt;\");\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 label.setContentMode(ContentMode.HTML);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Label labelDB = new Label();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 labelDB.setValue(\"&lt;p&gt;DB Path: \" + dbPath + \"&lt;\/p&gt;\");\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 labelDB.setContentMode(ContentMode.HTML);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Label labelQuery = new Label();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 labelQuery.setValue(\"&lt;p&gt;Query: \" + queryString + \"&lt;\/p&gt;\");\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 labelQuery.setContentMode(ContentMode.HTML);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 layout.addComponents(label, labelDB, labelQuery);\r\n\u00a0\u00a0\u00a0 }\r\n\r\n}<\/code><\/pre>\n<p>4. When opening the application inside the <em>names.nsf<\/em>, the result looks like this:<\/p>\n<p><a href=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2015\/01\/04-Result.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1954\" src=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2015\/01\/04-Result-300x87.png\" alt=\"04  - Result\" width=\"300\" height=\"87\" srcset=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2015\/01\/04-Result-300x87.png 300w, https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2015\/01\/04-Result.png 800w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When running your own servlet, you eventually want to access the Domino environment. To do this, some changes has to be made to the HelloVaadin plug-in. 1. Open the &#8222;MANFIFEST.MF&#8220; and open the &#8222;Dependencies&#8220; tab 2. Add the plug-in &#8222;com.ibm.osgi.domino.core&#8220; &hellip; <a href=\"https:\/\/hasselba.ch\/blog\/?p=1889\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[64,63],"tags":[7,65,66],"class_list":["post-1889","post","type-post","status-publish","format-standard","hentry","category-osgi","category-vaadin","tag-domino","tag-osgi","tag-vaadin"],"_links":{"self":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1889","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1889"}],"version-history":[{"count":3,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1889\/revisions"}],"predecessor-version":[{"id":1956,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1889\/revisions\/1956"}],"wp:attachment":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1889"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1889"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1889"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}