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.

VaadinOnGrailsMultipleUIs.asciidoc 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. ---
  2. title: Vaadin On Grails Multiple UIs
  3. order: 37
  4. layout: page
  5. ---
  6. [[vaadin-on-grails-multiple-uis]]
  7. = Vaadin on grails - multiple UIs
  8. _Versions used in this tutorial: Grails 2.3.x, Vaadin 7.1.x. News and
  9. updates about Vaadin on Grails are available on
  10. https://twitter.com/VaadinOnGrails[VaadinOnGrails]. This is continuation
  11. of <<VaadinOnGrailsDatabaseAccess#, Vaadin on Grails - Database access>>_
  12. In `grails-app/conf/VaadinConfig.groovy`, we can change URL mapping to
  13. UI. Also, we can define multiple UIs to be accessible from one Grails
  14. application.
  15. Create two new UIs that we will show under different URLs. `ClientUI`
  16. will be available on http://localhost:8080/client and `ServerUI` on
  17. http://localhost:8080/server
  18. [source,java]
  19. ....
  20. class ClientUI extends UI {
  21. protected void init(VaadinRequest request) {
  22. VerticalLayout layout = new VerticalLayout()
  23. layout.setMargin(true)
  24. Label label = new Label("Client")
  25. layout.addComponent(label)
  26. setContent(layout)
  27. }
  28. }
  29. class ServerUI extends UI {
  30. protected void init(VaadinRequest request) {
  31. VerticalLayout layout = new VerticalLayout()
  32. layout.setMargin(true)
  33. Label label = new Label("Server")
  34. layout.addComponent(label) setContent(layout)
  35. }
  36. }
  37. ....
  38. Open `VaadinConfig.groovy` and change the mapping, so the mapping points
  39. to the new UIs.
  40. ....
  41. mapping =
  42. [ "/client/*": "app.ClientUI",
  43. "/server/*": "app.ServerUI"]
  44. ....
  45. Now we can start up the application and access both URLs to see each is
  46. mapped to different UI class.
  47. image:http://vaadinongrails.com/img/mapping-uis.png[Mapping UIs]