Beispiel #1
0
 /**
  * Gets the currently used Vaadin portlet. The current portlet is automatically defined when
  * initializing the portlet and when processing requests to the server and in threads started at a
  * point when the current portlet is defined (see {@link InheritableThreadLocal}). In other cases,
  * (e.g. from background threads started in some other way), the current portlet is not
  * automatically defined.
  *
  * <p>The current portlet is derived from the current service using {@link
  * VaadinService#getCurrent()}
  *
  * @return the current vaadin portlet instance if available, otherwise <code>null</code>
  * @since 7.0
  */
 public static VaadinPortlet getCurrent() {
   VaadinService vaadinService = CurrentInstance.get(VaadinService.class);
   if (vaadinService instanceof VaadinPortletService) {
     VaadinPortletService vps = (VaadinPortletService) vaadinService;
     return vps.getPortlet();
   } else {
     return null;
   }
 }
Beispiel #2
0
 /**
  * Gets the currently used UI. The current UI is automatically defined when processing requests to
  * the server. In other cases, (e.g. from background threads), the current UI is not automatically
  * defined.
  *
  * @return the current UI instance if available, otherwise <code>null</code>
  * @see #setCurrent(UI)
  */
 public static UI getCurrent() {
   return CurrentInstance.get(UI.class);
 }