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.

BootstrapResponse.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright 2000-2014 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.server;
  17. import java.util.EventObject;
  18. import com.vaadin.ui.UI;
  19. /**
  20. * Base class providing common functionality used in different bootstrap
  21. * modification events.
  22. *
  23. * @author Vaadin Ltd
  24. * @since 7.0.0
  25. */
  26. public abstract class BootstrapResponse extends EventObject {
  27. private final VaadinRequest request;
  28. private final VaadinSession session;
  29. private final Class<? extends UI> uiClass;
  30. private final UIProvider uiProvider;
  31. /**
  32. * Creates a new bootstrap event.
  33. *
  34. * @param handler
  35. * the bootstrap handler that is firing the event
  36. * @param request
  37. * the Vaadin request for which the bootstrap page should be
  38. * generated
  39. * @param session
  40. * the session for which the bootstrap page should be generated
  41. * @param uiClass
  42. * the class of the UI that will be displayed on the page
  43. * @param uiProvider
  44. * the UI provider for the bootstrap
  45. */
  46. public BootstrapResponse(BootstrapHandler handler, VaadinRequest request,
  47. VaadinSession session, Class<? extends UI> uiClass,
  48. UIProvider uiProvider) {
  49. super(handler);
  50. this.request = request;
  51. this.session = session;
  52. this.uiClass = uiClass;
  53. this.uiProvider = uiProvider;
  54. }
  55. /**
  56. * Gets the bootstrap handler that fired this event
  57. *
  58. * @return the bootstrap handler that fired this event
  59. */
  60. public BootstrapHandler getBootstrapHandler() {
  61. return (BootstrapHandler) getSource();
  62. }
  63. /**
  64. * Gets the request for which the generated bootstrap HTML will be the
  65. * response. This can be used to read request headers and other additional
  66. * information. Please note that {@link VaadinRequest#getBrowserDetails()}
  67. * will not be available because the bootstrap page is generated before the
  68. * bootstrap javascript has had a chance to send any information back to the
  69. * server.
  70. *
  71. * @return the Vaadin request that is being handled
  72. */
  73. public VaadinRequest getRequest() {
  74. return request;
  75. }
  76. /**
  77. * Gets the service session to which the rendered view belongs.
  78. *
  79. * @return the Vaadin service session
  80. */
  81. public VaadinSession getSession() {
  82. return session;
  83. }
  84. /**
  85. * Gets the class of the UI that will be displayed on the generated
  86. * bootstrap page.
  87. *
  88. * @return the class of the UI
  89. */
  90. public Class<? extends UI> getUiClass() {
  91. return uiClass;
  92. }
  93. /**
  94. * Gets the UI provider that is used to provide information about the
  95. * bootstapped UI.
  96. *
  97. * @return the UI provider
  98. */
  99. public UIProvider getUIProvider() {
  100. return uiProvider;
  101. }
  102. }