Class Fragment<T extends com.vaadin.flow.component.Component>

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<T>
io.jmix.flowui.fragment.Fragment<T>
Type Parameters:
T - the type of the content
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasStyle, FragmentOwner, Serializable

public abstract class Fragment<T extends com.vaadin.flow.component.Component> extends com.vaadin.flow.component.Composite<T> implements FragmentOwner
A fragment encapsulates a Component tree to allow creation of new components by composing existing components. The main purpose of fragments is to be used as a part of views and other fragments. By encapsulating the component, its API can be hidden or presented in a different way for the user of the fragment.

The encapsulated component tree is available through Composite.getContent(). Fragment will by default look at the generic type declaration of its subclass to find the content type and create an instance using UiComponents. You can also override initContent() to manually create the component tree or define components tree using XML markup and bind it to a fragment using FragmentDescriptor.

Fragment is a way to hide API on the server side. It does not contribute any element to the Element tree.

See Also:
  • Field Details

  • Constructor Details

    • Fragment

      public Fragment()
  • Method Details

    • setUiComponents

      @Autowired public void setUiComponents(UiComponents uiComponents)
    • getFragmentData

      protected FragmentData getFragmentData()
    • setFragmentData

      protected void setFragmentData(FragmentData fragmentData)
    • getFragmentActions

      protected FragmentActions getFragmentActions()
    • setFragmentActions

      protected void setFragmentActions(FragmentActions fragmentActions)
    • getParentController

      protected FragmentOwner getParentController()
    • setParentController

      protected void setParentController(FragmentOwner parentController)
    • initContent

      protected T initContent()
      Overrides:
      initContent in class com.vaadin.flow.component.Composite<T extends com.vaadin.flow.component.Component>
    • getInnerComponent

      protected <C extends com.vaadin.flow.component.Component> C getInnerComponent(String id)
      Returns the inner component with given fragment id.
      Type Parameters:
      C - component type
      Parameters:
      id - fragment id
      Returns:
      the inner component with given fragment id
      Throws:
      IllegalArgumentException - if an inner component with given fragment id is not found
    • findInnerComponent

      protected <C extends com.vaadin.flow.component.Component> Optional<C> findInnerComponent(String id)
      Returns an Optional describing the inner component with given fragment id, or an empty Optional.
      Type Parameters:
      C - component type
      Parameters:
      id - fragment id
      Returns:
      an Optional describing the found component, or an empty Optional
    • addReadyListener

      protected com.vaadin.flow.shared.Registration addReadyListener(com.vaadin.flow.component.ComponentEventListener<Fragment.ReadyEvent> listener)
      Adds Fragment.ReadyEvent listener.
      Parameters:
      listener - the listener to add, not null
      Returns:
      a registration object that can be used for removing the listener