Class Extensions

java.lang.Object
io.jmix.ui.screen.Extensions

public final class Extensions extends Object
Extensions API for Screen and ScreenFragment.
  • Method Details

    • register

      public static <T> void register(FrameOwner frameOwner, Class<T> extensionClass, T extension)
      Register extension class in screen.
      Type Parameters:
      T - type of the extension
      Parameters:
      frameOwner - screen or screen fragment
      extensionClass - class of the extension
      extension - extension
    • get

      public static <T> T get(FrameOwner frameOwner, Class<T> extensionClass)
      Get extension instance.
      Type Parameters:
      T - type of extension
      Parameters:
      frameOwner - screen or screen fragment
      extensionClass - class of the extension
      Returns:
      extension
      Throws:
      IllegalStateException - in case extension class is not registered
    • getOptional

      public static <T> Optional<T> getOptional(FrameOwner frameOwner, Class<T> extensionClass)
      Get optional extension instance.
      Type Parameters:
      T - type of extension
      Parameters:
      frameOwner - screen or screen fragment
      extensionClass - class of the extension
      Returns:
      optional extension
    • remove

      public static void remove(FrameOwner frameOwner, Class<?> extensionClass)
      Remove extension instance.
      Parameters:
      frameOwner - screen or screen fragment
      extensionClass - class of the extension
    • getApplicationContext

      public static org.springframework.context.ApplicationContext getApplicationContext(FrameOwner frameOwner)
      Returns Spring ApplicationContext associated with the frame owner. Extensions can use it to get application beans.
      Example:
      
          ApplicationContext applicationContext = Extensions.getApplicationContext(screen);
          Messages messages = applicationContext.getBean(Messages.class);
       
      Parameters:
      frameOwner - UI controller