Package io.jmix.flowui.fragment
Class FragmentUtils
java.lang.Object
io.jmix.flowui.fragment.FragmentUtils
Utility class working with Jmix fragment specifics.
- 
Field SummaryFields
- 
Method SummaryModifier and TypeMethodDescriptionstatic Optional<com.vaadin.flow.component.Component>findComponent(Fragment<?> fragment, String id) static Class<? extends com.vaadin.flow.component.Component>findContentType(Class<? extends Fragment<?>> fragmentClass) Returns a class that represents the type of the fragment contentgetComponentId(com.vaadin.flow.component.Component component) Gets the fragment id of the passed component.static FragmentActionsgetFragmentActions(Fragment<?> fragment) GetsFragmentActionsobject from passedFragment.static FragmentDatagetFragmentData(Fragment<?> fragment) GetsFragmentDataobject from passedFragment.static StringgetMessageGroup(String descriptorPath) Gets message group from the passed descriptor path.static StringgetPackage(Class<? extends com.vaadin.flow.component.Component> componentClass) Gets the package of the passed class.static FragmentOwnergetParentController(Fragment<?> fragment) Gets the owner of the passedFragment.static StringresolveDescriptorPath(Class<? extends com.vaadin.flow.component.Component> componentClass) Resolves a path to the XML descriptor.static booleanReturns whether the component has the same fragment id as passed.static voidsetComponentId(com.vaadin.flow.component.Component component, String id) Sets the fragment id to the passed component.static voidsetFragmentActions(Fragment<?> fragment, FragmentActions actions) SetsFragmentActionsobject to passedFragment.static voidsetFragmentData(Fragment<?> fragment, FragmentData data) SetsFragmentDataobject to passedFragment.static voidsetParentController(Fragment<?> fragment, FragmentOwner parentController) Sets the owner to the passedFragment.
- 
Field Details- 
ID_KEY- See Also:
 
 
- 
- 
Method Details- 
getComponentIdGets the fragment id of the passed component.Note: Fragment id is stored in the component Attributesfield instead of setting it as actual id usingComponent.setId(String). This is done to avoid id duplicates in components tree when several fragments of the same type is used simultaneously or fragment inner components have the same id as other components in the components tree- Parameters:
- component- the component to get fragment id
- Returns:
- the fragment id of the passed component
 
- 
setComponentIdSets the fragment id to the passed component.Note: Fragment id is stored in the component Attributesfield instead of setting it as actual id usingComponent.setId(String). This is done to avoid id duplicates in components tree when several fragments of the same type is used simultaneously or fragment inner components have the same id as other components in the components tree- Parameters:
- component- component to set fragment id
- id- id to set
 
- 
getFragmentDataGetsFragmentDataobject from passedFragment.- Parameters:
- fragment- fragment to get data holder
- Returns:
- FragmentDataobject from passed- Fragment
 
- 
setFragmentDataSetsFragmentDataobject to passedFragment.- Parameters:
- fragment- fragment to set data holder
- data- data holder to set
 
- 
getFragmentActionsGetsFragmentActionsobject from passedFragment.- Parameters:
- fragment- fragment to get actions holder
- Returns:
- FragmentActionsobject from passed- Fragment
 
- 
setFragmentActionsSetsFragmentActionsobject to passedFragment.- Parameters:
- fragment- fragment to set actions holder
- actions- actions holder to set
 
- 
getParentControllerGets the owner of the passedFragment.- Parameters:
- fragment- fragment to get the owner
- Returns:
- the owner of the passed fragment
 
- 
setParentControllerSets the owner to the passedFragment.- Parameters:
- fragment- fragment to set the owner
- parentController- the owner
 
- 
sameIdReturns whether the component has the same fragment id as passed.- Parameters:
- component- component to compare id
- id- id to compare
- Returns:
- trueif the component has the same fragment id as passed,- falseotherwise
- See Also:
 
- 
findComponentpublic static Optional<com.vaadin.flow.component.Component> findComponent(Fragment<?> fragment, String id) 
- 
findContentTypepublic static Class<? extends com.vaadin.flow.component.Component> findContentType(Class<? extends Fragment<?>> fragmentClass) Returns a class that represents the type of the fragment content- Parameters:
- fragmentClass- the fragment class to get the type of content
- Returns:
- a class that represents the type of the fragment content
- Throws:
- IllegalStateException- if either fragment is used as raw type or it is impossible to determine the fragment content type
 
- 
getPackagepublic static String getPackage(Class<? extends com.vaadin.flow.component.Component> componentClass) Gets the package of the passed class.- Parameters:
- componentClass- a class to get package
- Returns:
- the package of the passed class
 
- 
getMessageGroupGets message group from the passed descriptor path.- Parameters:
- descriptorPath- descriptor path to get message group
- Returns:
- message group from the passed descriptor path
 
- 
resolveDescriptorPath@Nullable public static String resolveDescriptorPath(Class<? extends com.vaadin.flow.component.Component> componentClass) Resolves a path to the XML descriptor. If the value contains a file name only (i.e. don't start with '/'), it is assumed that the file is located in the package of the fragment class.- Parameters:
- componentClass- a component class for which to resolve XML descriptor path
- Returns:
- a path to the XML descriptor
 
 
-