Class MessageTemplateFragment

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<JmixFormLayout>
io.jmix.flowui.fragment.Fragment<JmixFormLayout>
io.jmix.bpmflowui.view.modeler.properties.notification.MessageTemplateFragment
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasStyle, FacetOwner, FragmentOwner, Serializable

public class MessageTemplateFragment extends Fragment<JmixFormLayout>
Lets the notification editor pick a reusable message template, storing only the template's code.

Referencing the Message Templates add-on's MessageTemplate, it is instantiated by the host only when that add-on is present, keeping the host itself free of add-on types.

See Also:
  • Field Details

  • Constructor Details

    • MessageTemplateFragment

      public MessageTemplateFragment()
  • Method Details

    • setTemplateCode

      public void setTemplateCode(@Nullable String templateCode)
      Selects the template with the given code (checking the box and revealing the picker), or clears the selection when no code is given. Used to initialize the fragment from the edited notification.
      Parameters:
      templateCode - stored template code, or null/empty when no template is used
    • setTemplateCodeChangeListener

      public void setTemplateCodeChangeListener(@Nullable Consumer<String> listener)
      Registers a listener notified whenever the selected template code changes (a code, or null when no template is used).
      Parameters:
      listener - consumer of the current template code
    • isTemplateUsed

      public boolean isTemplateUsed()
      Returns whether the "use message template" option is on, regardless of whether a template has been picked yet.
      Returns:
      true when the use-template checkbox is checked
    • getTemplateCode

      public @Nullable String getTemplateCode()
      Returns the code of the currently selected template.
      Returns:
      the selected template code, or null when the checkbox is off or nothing is picked
    • onUseTemplateCheckboxValueChange

      @Subscribe("useTemplateCheckbox") public void onUseTemplateCheckboxValueChange(com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<JmixCheckbox,Boolean> event)
    • onTemplatePickerValueChange

      @Subscribe("templatePicker") public void onTemplatePickerValueChange(com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EntityPicker<MessageTemplate>,MessageTemplate> event)
    • notifyTemplateCodeChanged

      protected void notifyTemplateCodeChanged()
    • loadByCode

      protected @Nullable MessageTemplate loadByCode(String code)