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.

portal-ui.asciidoc 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ---
  2. title: Portlet UI
  3. order: 4
  4. layout: page
  5. ---
  6. [[portal.ui]]
  7. = Portlet UI
  8. A portlet UI is just like in a regular Vaadin application, a class that extends
  9. [classname]#com.vaadin.ui.UI#.
  10. ----
  11. @Theme("myportlet")
  12. public class MyportletUI extends UI {
  13. @Override
  14. protected void init(VaadinRequest request) {
  15. final VerticalLayout layout = new VerticalLayout();
  16. layout.setMargin(true);
  17. setContent(layout);
  18. Button button = new Button("Click Me");
  19. button.addClickListener(new Button.ClickListener() {
  20. public void buttonClick(ClickEvent event) {
  21. layout.addComponent(
  22. new Label("Thank you for clicking"));
  23. }
  24. });
  25. layout.addComponent(button);
  26. }
  27. }
  28. ----
  29. If you created the project as a Servlet 3.0 project, the generated UI stub
  30. includes a static servlet class annotated with [classname]#@WebServlet#, as
  31. described in
  32. <<dummy/../../../framework/getting-started/getting-started-first-project#getting-started.first-project.exploring,"Exploring
  33. the Project">>.
  34. ----
  35. @WebServlet(value = "/*", asyncSupported = true)
  36. @VaadinServletConfiguration(productionMode = false,
  37. ui = MyportletUI.class)
  38. public static class Servlet extends VaadinServlet {
  39. }
  40. ----
  41. This enables running the portlet UI in a servlet container while developing it,
  42. which may be easier than deploying to a portal. For Servlet 2.4 projects, a
  43. [filename]#web.xml# is created.
  44. The portlet theme is defined with the [classname]#@Theme# annotation as usual.
  45. The theme for the UI must match a theme installed in the portal. You can use any
  46. of the built-in themes in Vaadin. If you use a custom theme, you need to
  47. compile it to CSS with the theme compiler and install it in the portal under the
  48. [filename]#VAADIN/themes# context to be served statically.
  49. In addition to the UI class, you need the portlet descriptor files, Vaadin
  50. libraries, and other files as described later.
  51. <<figure.portal.helloworld.project>> shows the complete project structure under
  52. Eclipse.
  53. [[figure.portal.helloworld.project]]
  54. .Portlet Project Structure in Eclipse
  55. image::img/liferay-project.png[]
  56. Installed as a portlet in Liferay from the [guilabel]#Add Application# menu, the
  57. application will show as illustrated in <<figure.portal.helloworld>>.
  58. [[figure.portal.helloworld]]
  59. .Hello World Portlet
  60. image::img/liferay-helloworld.png[]