Class AbstractLookupAction<E>

Type Parameters:
E - type of entity
All Implemented Interfaces:
Action, Action.HasPrimaryState, Action.ScreenOpeningAction, Action.SecuredAction
Direct Known Subclasses:
EntityLookupAction, TagLookupAction

public abstract class AbstractLookupAction<E> extends BaseAction implements Action.ScreenOpeningAction
Base class for actions that should open a screen.
  • Field Details

  • Constructor Details

    • AbstractLookupAction

      public AbstractLookupAction(String id)
  • Method Details

    • setScreenBuilders

      @Autowired public void setScreenBuilders(ScreenBuilders screenBuilders)
    • setIcons

      @Autowired protected void setIcons(Icons icons)
    • setMessages

      @Autowired protected void setMessages(Messages messages)
    • getOpenMode

      @Nullable public OpenMode getOpenMode()
      Returns the lookup screen open mode if it was set by setOpenMode(OpenMode) or in the screen XML. Otherwise returns null.
      Specified by:
      getOpenMode in interface Action.ScreenOpeningAction
    • setOpenMode

      @StudioPropertiesItem public void setOpenMode(@Nullable OpenMode openMode)
      Sets the lookup screen open mode.
      Specified by:
      setOpenMode in interface Action.ScreenOpeningAction
      Parameters:
      openMode - the open mode to set
    • getScreenId

      @Nullable public String getScreenId()
      Returns the lookup screen id if it was set by setScreenId(String) or in the screen XML. Otherwise returns null.
      Specified by:
      getScreenId in interface Action.ScreenOpeningAction
    • setScreenId

      @StudioPropertiesItem public void setScreenId(@Nullable String screenId)
      Sets the lookup screen id.
      Specified by:
      setScreenId in interface Action.ScreenOpeningAction
      Parameters:
      screenId - the screen id to set
    • getScreenClass

      @Nullable public Class<? extends Screen> getScreenClass()
      Returns the lookup screen class if it was set by setScreenClass(Class) or in the screen XML. Otherwise returns null.
      Specified by:
      getScreenClass in interface Action.ScreenOpeningAction
    • setScreenClass

      @StudioPropertiesItem public void setScreenClass(@Nullable Class<? extends Screen> screenClass)
      Sets the lookup screen id.
      Specified by:
      setScreenClass in interface Action.ScreenOpeningAction
      Parameters:
      screenClass - the screen class to set
    • setScreenOptionsSupplier

      public void setScreenOptionsSupplier(Supplier<ScreenOptions> screenOptionsSupplier)
      Sets the lookup screen options supplier. The supplier provides ScreenOptions to the opened screen.

      The preferred way to set the supplier is using a controller method annotated with Install, e.g.:

       @Install(to = "petField.lookup", subject = "screenOptionsSupplier")
       protected ScreenOptions petFieldLookupScreenOptionsSupplier() {
           return new MapScreenOptions(ParamsMap.of("someParameter", 10));
       }
       
      Specified by:
      setScreenOptionsSupplier in interface Action.ScreenOpeningAction
    • setScreenConfigurer

      public void setScreenConfigurer(Consumer<Screen> screenConfigurer)
      Sets the lookup screen configurer. Use the configurer if you need to provide parameters to the opened screen through setters.

      The preferred way to set the configurer is using a controller method annotated with Install, e.g.:

       @Install(to = "petField.lookup", subject = "screenConfigurer")
       protected void petFieldLookupScreenConfigurer(Screen lookupScreen) {
           ((PetBrowse) lookupScreen).setSomeParameter(someValue);
       }
       
      Specified by:
      setScreenConfigurer in interface Action.ScreenOpeningAction
    • setAfterCloseHandler

      public void setAfterCloseHandler(Consumer<Screen.AfterCloseEvent> afterCloseHandler)
      Sets the handler to be invoked when the lookup screen closes.

      The preferred way to set the handler is using a controller method annotated with Install, e.g.:

       @Install(to = "petField.lookup", subject = "afterCloseHandler")
       protected void petFieldLookupAfterCloseHandler(AfterCloseEvent event) {
           CloseAction closeAction = event.getCloseAction();
           System.out.println("Closed with " + closeAction);
       }
       
      Specified by:
      setAfterCloseHandler in interface Action.ScreenOpeningAction
    • setSelectValidator

      public void setSelectValidator(Predicate<LookupScreen.ValidationContext<E>> selectValidator)
      Sets the validator to be invoked when the user selects entities in the lookup screen.

      The preferred way to set the validator is using a controller method annotated with Install, e.g.:

       @Install(to = "petField.lookup", subject = "selectValidator")
       protected void petFieldLookupSelectValidator(LookupScreen.ValidationContext<Pet> context) {
           return checkSelected(context.getSelectedItems());
       }
       
    • setTransformation

      public void setTransformation(Function<Collection<E>,Collection<E>> transformation)
      Sets the function to transform selected in the lookup screen entities.

      The preferred way to set the function is using a controller method annotated with Install, e.g.:

       @Install(to = "petField.lookup", subject = "transformation")
       protected Collection<Pet> petFieldLookupTransformation(Collection<Pet> entities) {
           return doTransform(entities);
       }