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.

HtmlImport.java 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright 2000-2016 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.annotations;
  17. import java.lang.annotation.Documented;
  18. import java.lang.annotation.ElementType;
  19. import java.lang.annotation.Repeatable;
  20. import java.lang.annotation.Retention;
  21. import java.lang.annotation.RetentionPolicy;
  22. import java.lang.annotation.Target;
  23. import com.vaadin.server.ClientConnector;
  24. /**
  25. * If this annotation is present on a {@link ClientConnector} class, the
  26. * framework ensures the referenced HTML imports are loaded before the init
  27. * method for the corresponding client-side connector is invoked.
  28. * <p>
  29. * Note that not all browsers yet support HTML imports. If a polyfill is needed
  30. * to load HTML imports, it must be loaded before HTML Imports can be loaded.
  31. * There is no automatic loading of any polyfill.
  32. * <p>
  33. * <ul>
  34. * <li>Relative URLs are mapped to APP/PUBLISHED/[url] which are by default
  35. * served from the classpath relative to the class where the annotation is
  36. * defined.
  37. * <li>Absolute URLs including protocol and host are used as is on the
  38. * client-side.
  39. * </ul>
  40. * Note that it is a good idea to use URLs starting with {@literal vaadin://}
  41. * and place all HTML imports inside {@literal VAADIN/bower_components}. Polymer
  42. * elements rely on importing dependencies using relative paths
  43. * {@literal ../../other-element/other-element.html}, which will not work if
  44. * they are installed in different locations.
  45. * <p>
  46. * HTML imports are added to the page after any {@code @JavaScript} dependencies
  47. * added at the same time.
  48. * <p>
  49. * Example:
  50. * <code>@HtmlImport("bower_components/paper-slider/paper-slider.html")</code>
  51. * on the class com.example.MyConnector would load the file
  52. * http://host.com/VAADIN/bower_components/paper-slider/paper-slider.html before
  53. * the {@code init()} method of the client side connector is invoked.
  54. *
  55. * @author Vaadin Ltd
  56. * @since 8.0.0
  57. */
  58. @Retention(RetentionPolicy.RUNTIME)
  59. @Target(ElementType.TYPE)
  60. @Documented
  61. @Repeatable(InternalContainerAnnotationForHtml.class)
  62. public @interface HtmlImport {
  63. /**
  64. * HTML file URL(s) to load before using the annotated
  65. * {@link ClientConnector} in the browser.
  66. *
  67. * @return html file URL(s) to load
  68. */
  69. String[] value();
  70. }