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.

DevelopingPortletsForTheWebSpherePortalServer.asciidoc 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. ---
  2. title: Developing Portlets For The WebSphere Portal Server
  3. order: 4
  4. layout: page
  5. ---
  6. [[developing-portlets-for-the-websphere-portal-server]]
  7. = Developing portlets for the Websphere Portal Server
  8. When creating portlets for the Websphere Portal Server (aka WPS) you
  9. have the choice between different frameworks
  10. * JSF (2.0)
  11. * Spring Portlet MVC
  12. * Vaadin 6 / 7
  13. While using JSF seems to be a bit outdated, because WPS just supports an
  14. old JSF Version (MyFaces 2.0.2) Spring Portlet MVC is a good and valid
  15. options for developing portlets.
  16. On this page I will try to collect all information to
  17. develop Vaadin portlets in a fast and easy to use way. I will also
  18. handle topics like using CDI and the navigator in a portal environment
  19. as well as some architectural ideas like using the MVP pattern for a
  20. portlet project. As an example portlet I will use a simple master /
  21. detail portlet just like the Vaadin address book application. I have
  22. developed all code examples on this wiki pages with the current Vaadin
  23. version (7.4.2 as I am writing this) and tested the portlets on WPS 8.0
  24. and 8.5.
  25. I use Maven for dependency management and SLF4J for logging. You can
  26. download the small zipped project in the attachments section. Please,
  27. feel free to leave comments and / or questions on the bottom of the
  28. page.
  29. [[a-simple-portlet]]
  30. A simple Portlet
  31. ~~~~~~~~~~~~~~~~
  32. Lets start with a "Click Me" (aka "Hello World") Vaading portlet.
  33. The UI class is identical to servlet development (create a button with a
  34. click listener and show a notification when clicking the button). The
  35. interesting part is the configuration of the portlet.xml file.
  36. [[portlet.xml]]
  37. Portlet.xml
  38. ^^^^^^^^^^^
  39. [source,xml]
  40. ....
  41. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  42. <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" id="com.gisag.vaadin.ClickMeUI">     
  43. <portlet>         
  44. <description>Vaadin Click Me Portlet </description>         
  45. <portlet-name>Vaadin Click Me Portlet</portlet-name>         
  46. <display-name>Vaadin Click Me Portlet</display-name>        
  47. <portlet-class>com.vaadin.server.VaadinPortlet</portlet-class>
  48. <init-param>           
  49. <name>UI</name>           
  50. <value>com.gisag.vaadin.ClickMeUI</value>         
  51. </init-param>         
  52. <init-param>             
  53. <name>productionMode</name>             
  54. <value>false</value>         
  55. </init-param>     
  56.     
  57. <init-param>           
  58. <description>Path of all static vaadin resources (configurable from context root)</description>             
  59. <name>vaadin.resources.path</name>             
  60. <value>PORTLET_CONTEXT</value>       
  61. </init-param>
  62. <!-- Supported portlet modes and content types. -->         
  63. <supports>             
  64. <mime-type>text/html</mime-type>             
  65. <portlet-mode>view</portlet-mode>         
  66. </supports>     
  67. </portlet>
  68. </portlet-app>
  69. ....
  70. In the `portlet` tag you have to set a value for the `portlet-class`. For
  71. this simple we can use the default Vaadin portlet class
  72. `com.vaadin.server.VaadinPortlet`; you also have to name you UI class as a
  73. portlet init parameter.
  74. To let WPS find the Vaadin javascript and theme resources you have to
  75. use the portlet init parameter `vaadin.resources.path`. The value
  76. `PORTLET_CONTEXT` is a Vaadin constant value that makes the vaadin
  77. resources available in the portlets resource path.
  78. Run the Maven build with `clean package` as goals and deploy the created
  79. war file in the portal administration. Create a blank portal page and
  80. add your portlet to the page. Your "Click me" portlet should look like
  81. this:
  82. image:img/Click_Me_2015-03-31_21-03-27.png[Your first portlet]