Interface TagField<V>

Type Parameters:
V - type of value
All Superinterfaces:
Component, Component.BelongToFrame, Component.Editable, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Field<Collection<V>>, HasContextHelp, HasEnterPressHandler, HasFormatter<V>, HasHtmlCaption, HasHtmlDescription, HasHtmlSanitizer, HasInputPrompt, HasOptionStyleProvider<V>, HasValidator<Collection<V>>, HasValue<Collection<V>>, HasValueSource<Collection<V>>, Requirable, SuggestionFieldComponent<Collection<V>,V>, SupportsUserAction<Collection<V>>, Validatable
All Known Implementing Classes:
TagFieldImpl

@StudioComponent(caption="TagField", category="Components", xmlElement="tagField", canvasBehaviour=INPUT_FIELD, documentationURL="https://docs.jmix.io/jmix/%VERSION%/ui/vcl/components/tag-field.html", icon="io/jmix/ui/icon/component/tagField.svg") public interface TagField<V> extends SuggestionFieldComponent<Collection<V>,V>, SupportsUserAction<Collection<V>>
The field that search and shows selected values as separated tags right in the field.
  • Field Details

  • Method Details

    • of

      static <T> org.springframework.core.ParameterizedTypeReference<TagField<T>> of(Class<T> valueClass)
    • setSearchExecutor

      void setSearchExecutor(@Nullable SuggestionFieldComponent.SearchExecutor<V> searchExecutor)
      Description copied from interface: SuggestionFieldComponent
      Sets SuggestionFieldComponent.SearchExecutor which performs search.
      Specified by:
      setSearchExecutor in interface SuggestionFieldComponent<Collection<V>,V>
      Parameters:
      searchExecutor - SearchExecutor instance
    • isClearAllVisible

      boolean isClearAllVisible()
      Returns:
      {code true} if clear button is visible
    • setClearAllVisible

      @StudioProperty(name="clearAllVisible", defaultValue="false") void setClearAllVisible(boolean visible)
      Display the button that clears all tags from the field. The default value is false.
      Parameters:
      visible - whether to display clear button
    • getTagStyleProvider

      @Nullable Function<? super V,String> getTagStyleProvider()
      Returns:
      tag style provider or null if not set
    • setTagStyleProvider

      void setTagStyleProvider(@Nullable Function<? super V,String> tagStyleProvider)
      Sets tag style provider. It is used for generating style name for tag.

      For instance:

       @Install(to = "tagField", subject = "tagStyleProvider")
       private String tagFieldTagStyleProvider(User user) {
           switch (user.getAccountType()) {
               case PREMIUM:
                   return "user-premium";
               case COMMON:
                   return "user-common";
               default:
                   return null;
           }
       }
       
      Parameters:
      tagStyleProvider - tag style provider to set
    • getTagCaptionProvider

      @Nullable Function<? super V,String> getTagCaptionProvider()
      Returns:
      tag caption provider or null if not set
    • setTagCaptionProvider

      void setTagCaptionProvider(@Nullable Function<? super V,String> tagCaptionProvider)
      Sets tag caption provider. It is used for generating tag caption.

      For instance:

       @Install(to = "tagField", subject = "tagCaptionProvider")
       private String tagFieldCaptionProvider(User user) {
           return "User: " + user.getUsername();
       }
       
      Parameters:
      tagCaptionProvider - caption provider to set
    • getTagComparator

      @Nullable Comparator<? super V> getTagComparator()
      Returns:
      tag comparator
    • setTagComparator

      void setTagComparator(@Nullable Comparator<? super V> tagComparator)
      Sets comparator for sorting tags in the UI.
      Parameters:
      tagComparator - comparator to set
    • addTagClickListener

      Subscription addTagClickListener(Consumer<TagField.TagClickEvent<V>> listener)
      Sets tag click listener. It subscribes to TagField.TagClickEvent that is invoked when user clicks on tag content.
      Parameters:
      listener - listener to add
      Returns:
      a registration object for removing an event listener