{"id":2249,"date":"2016-05-03T13:15:31","date_gmt":"2016-05-03T11:15:31","guid":{"rendered":"http:\/\/hasselba.ch\/blog\/?p=2249"},"modified":"2016-05-03T13:15:31","modified_gmt":"2016-05-03T11:15:31","slug":"vaadin-in-xpages-a-uicomponent-for-embedding-vaadin-applications","status":"publish","type":"post","link":"https:\/\/hasselba.ch\/blog\/?p=2249","title":{"rendered":"Vaadin In XPages: A UIComponent for embedding Vaadin applications"},"content":{"rendered":"<p>I have created an UIComponent to embed Vaadin applications into XPages. It allows to run both technologies on the same site by adding it to your XPage:<\/p>\n<pre><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;xp:view\r\n\u00a0\u00a0 \u00a0xmlns:xp=\"http:\/\/www.ibm.com\/xsp\/core\"\r\n\u00a0\u00a0 \u00a0xmlns:vaadin=\"http:\/\/vaadin.com\/xsp\/control\"\r\n\u00a0\u00a0 \u00a0createForm=\"false\"&gt;\r\n\u00a0\u00a0 \u00a0\r\n\r\n\u00a0\u00a0 \u00a0&lt;!-- XPages Application --&gt;\r\n\u00a0\u00a0 \u00a0&lt;xp:form&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;xp:div id=\"refreshMe\"&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;h1&gt;XPage&lt;\/h1&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;xp:label\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0value=\"#{javascript:java.lang.System.nanoTime()}\"\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0id=\"label1\"&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;\/xp:label&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;\/xp:div&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;xp:button\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0value=\"refresh\"\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0id=\"button1\"&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;xp:eventHandler\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0event=\"onclick\"\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0submit=\"true\"\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0refreshMode=\"partial\"\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0refreshId=\"refreshMe\"&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;\/xp:eventHandler&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;\/xp:button&gt;\r\n\u00a0\u00a0 \u00a0&lt;\/xp:form&gt;\r\n\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0&lt;!--\u00a0 VAADIN Application --&gt;\r\n\u00a0\u00a0 \u00a0&lt;vaadin:Vaadin\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0id=\"Vaadin1\"\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0url = \"\/vaadin\/\"\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0divId=\"addressbook\"\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0version=\"7.3.8\"\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0forceResize=\"true\" \/&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\r\n&lt;\/xp:view&gt;<\/code><\/pre>\n<p>This little example shows the XPage above including the <a href=\"https:\/\/hasselba.ch\/blog\/?p=1891\">the Adressbook application:<\/a><\/p>\n<p><a href=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2016\/05\/2016-05-03-12_31_17-VaadinInXPages.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2250\" src=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2016\/05\/2016-05-03-12_31_17-VaadinInXPages.png\" alt=\"2016-05-03 12_31_17-VaadinInXPages\" width=\"807\" height=\"531\" srcset=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2016\/05\/2016-05-03-12_31_17-VaadinInXPages.png 807w, https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2016\/05\/2016-05-03-12_31_17-VaadinInXPages-300x197.png 300w, https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2016\/05\/2016-05-03-12_31_17-VaadinInXPages-768x505.png 768w\" sizes=\"auto, (max-width: 807px) 100vw, 807px\" \/><\/a><\/p>\n<p>The Vaadin application is reachable at &#8222;<em>http:\/\/localhost\/vaadin\/<\/em>&#8220; (hosted by Domino), that&#8217;s why the property <em>url<\/em> is set to &#8222;<em>\/vaadin\/<\/em>&#8222;. The property <em>divId<\/em> contains the name of the application which is used as id in the DOM tree.<\/p>\n<p>It is required that the <em>VaadinComponent<\/em> is not inside a <em>xp:form<\/em> element. If it detects a surrounding form, a runtime exception is thrown. That&#8217;s why you have to set <em>createForm<\/em> to <em>false<\/em> and add your own <em>xp:form<\/em> to your application, as shown in the example.<\/p>\n<p><a href=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2016\/05\/2016-05-03-12_50_11-Runtime-Error.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2251\" src=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2016\/05\/2016-05-03-12_50_11-Runtime-Error.png\" alt=\"2016-05-03 12_50_11-Runtime Error\" width=\"507\" height=\"343\" srcset=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2016\/05\/2016-05-03-12_50_11-Runtime-Error.png 507w, https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2016\/05\/2016-05-03-12_50_11-Runtime-Error-300x203.png 300w\" sizes=\"auto, (max-width: 507px) 100vw, 507px\" \/><\/a><\/p>\n<p>If the parameter <em>forceResize<\/em> is set to <em>true<\/em>, a CSS style sheet is added to the XPage which resizes the height of html and the body node to 100%. Otherwise the Vaadin application will not be displayed correctly.<\/p>\n<p><a href=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2016\/05\/2016-05-03-12_54_35-view-source_localhost_VaadinInXPages.nsf_index.xsp_.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2253\" src=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2016\/05\/2016-05-03-12_54_35-view-source_localhost_VaadinInXPages.nsf_index.xsp_.png\" alt=\"2016-05-03 12_54_35-view-source_localhost_VaadinInXPages.nsf_index.xsp\" width=\"799\" height=\"294\" srcset=\"https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2016\/05\/2016-05-03-12_54_35-view-source_localhost_VaadinInXPages.nsf_index.xsp_.png 799w, https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2016\/05\/2016-05-03-12_54_35-view-source_localhost_VaadinInXPages.nsf_index.xsp_-300x110.png 300w, https:\/\/hasselba.ch\/blog\/wp-content\/uploads\/2016\/05\/2016-05-03-12_54_35-view-source_localhost_VaadinInXPages.nsf_index.xsp_-768x283.png 768w\" sizes=\"auto, (max-width: 799px) 100vw, 799px\" \/><\/a><\/p>\n<p>Resource Aggregation must be disabled, otherwise it won&#8217;t work.<\/p>\n<p>The sources can be found at <a href=\"https:\/\/github.com\/hasselbach\/VaadinInXPages\">https:\/\/github.com\/hasselbach\/VaadinInXPages<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have created an UIComponent to embed Vaadin applications into XPages. It allows to run both technologies on the same site by adding it to your XPage: &lt;?xml version=&#8220;1.0&#8243; encoding=&#8220;UTF-8&#8243;?&gt; &lt;xp:view \u00a0\u00a0 \u00a0xmlns:xp=&#8220;http:\/\/www.ibm.com\/xsp\/core&#8220; \u00a0\u00a0 \u00a0xmlns:vaadin=&#8220;http:\/\/vaadin.com\/xsp\/control&#8220; \u00a0\u00a0 \u00a0createForm=&#8220;false&#8220;&gt; \u00a0\u00a0 \u00a0 \u00a0\u00a0 &hellip; <a href=\"https:\/\/hasselba.ch\/blog\/?p=2249\">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":[63,74],"tags":[66,3],"class_list":["post-2249","post","type-post","status-publish","format-standard","hentry","category-vaadin","category-xpages","tag-vaadin","tag-xpages"],"_links":{"self":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2249","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=2249"}],"version-history":[{"count":3,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2249\/revisions"}],"predecessor-version":[{"id":2255,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2249\/revisions\/2255"}],"wp:attachment":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}