Class CreateAction<E>

All Implemented Interfaces:
AdjustWhenScreenReadOnly, ExecutableAction, ScreenOpeningAction, SecuredAction, TargetAction<ListDataComponent<E>>, Action

@ActionType("create") public class CreateAction<E> extends ListDataComponentAction<CreateAction<E>,E> implements AdjustWhenScreenReadOnly, ScreenOpeningAction, ExecutableAction
  • Field Details

  • Constructor Details

    • CreateAction

      public CreateAction()
    • CreateAction

      public CreateAction(String id)
  • Method Details

    • initAction

      protected void initAction()
      Overrides:
      initAction in class ListDataComponentAction<CreateAction<E>,E>
    • getOpenMode

      @Nullable public OpenMode getOpenMode()
      Description copied from interface: ScreenOpeningAction
      Returns the screen open mode if it was set by ScreenOpeningAction.setOpenMode(OpenMode) or in the screen XML, otherwise returns null.
      Specified by:
      getOpenMode in interface ScreenOpeningAction
    • setOpenMode

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

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

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

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

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

      @Nullable public com.vaadin.flow.router.RouteParameters getRouteParameters()
      Specified by:
      getRouteParameters in interface ScreenOpeningAction
      Returns:
      route parameters or null if not set
    • setRouteParameters

      public void setRouteParameters(@Nullable com.vaadin.flow.router.RouteParameters routeParameters)
      Description copied from interface: ScreenOpeningAction
      Sets route parameters that should be used in the route template.

      Note that route parameters are set if the editor is opened in OpenMode.NAVIGATION.

      Specified by:
      setRouteParameters in interface ScreenOpeningAction
      Parameters:
      routeParameters - route parameters to set
      See Also:
      • Route
    • getQueryParameters

      @Nullable public com.vaadin.flow.router.QueryParameters getQueryParameters()
      Specified by:
      getQueryParameters in interface ScreenOpeningAction
      Returns:
      query parameters or null if not set
    • setQueryParameters

      public void setQueryParameters(@Nullable com.vaadin.flow.router.QueryParameters queryParameters)
      Description copied from interface: ScreenOpeningAction
      Sets query parameters that should be used in the URL.

      Note that query parameters are set if the editor is opened in OpenMode.NAVIGATION.

      Specified by:
      setQueryParameters in interface ScreenOpeningAction
      Parameters:
      queryParameters - query parameters to set
    • setAfterCloseHandler

      public <S extends Screen<?>> void setAfterCloseHandler(@Nullable Consumer<DialogWindow.AfterCloseEvent<S>> afterCloseHandler)
      Description copied from interface: ScreenOpeningAction
      Sets the handler to be invoked when the editor screen closes.

      Note that handler is invoked if the editor is opened in OpenMode.DIALOG mode.

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

       @Install(to = "petsTable.view", subject = "afterCloseHandler")
       protected void petsTableViewAfterCloseHandler(AfterCloseEvent event) {
           if (event.closedWith(StandardOutcome.COMMIT)) {
               System.out.println("Committed");
           }
       }
       
      Specified by:
      setAfterCloseHandler in interface ScreenOpeningAction
      Type Parameters:
      S - screen type
      Parameters:
      afterCloseHandler - handler to set
    • setInitializer

      public void setInitializer(@Nullable Consumer<E> initializer)
      Sets the new entity initializer. The initializer accepts the new entity instance and can perform its initialization.

      Note that initializer is invoked if the editor is opened in OpenMode.DIALOG mode.

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

       @Install(to = "petsTable.create", subject = "initializer")
       protected void petsTableCreateInitializer(Pet entity) {
           entity.setName("a cat");
       }
       
    • setAfterCommitHandler

      public void setAfterCommitHandler(@Nullable Consumer<E> afterCommitHandler)
      Sets the handler to be invoked when the editor screen commits the new entity.

      Note that handler is invoked if the editor is opened in OpenMode.DIALOG mode.

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

       @Install(to = "petsTable.create", subject = "afterCommitHandler")
       protected void petsTableCreateAfterCommitHandler(Pet entity) {
           System.out.println("Created " + entity);
       }
       
    • setTransformation

      public void setTransformation(@Nullable Function<E,E> transformation)
      Sets the function to transform the committed in the editor screen entity before setting it to the target data container.

      Note that transformation function is invoked if the editor is opened in OpenMode.DIALOG mode.

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

       @Install(to = "petsTable.create", subject = "transformation")
       protected Pet petsTableCreateTransformation(Pet entity) {
           return doTransform(entity);
       }
       
    • setNewEntitySupplier

      public void setNewEntitySupplier(@Nullable Supplier<E> newEntitySupplier)
      Sets the new entity supplier. The supplier should return a new entity instance.

      Note that supplier is invoked if the editor is opened in OpenMode.DIALOG mode.

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

       @Install(to = "petsTable.create", subject = "newEntitySupplier")
       protected Pet petsTableCreateNewEntitySupplier() {
           Pet pet = metadata.create(Pet.class);
           pet.setName("a cat");
           return pet;
       }
       
    • setMessages

      @Autowired protected void setMessages(Messages messages)
    • setFlowUiComponentProperties

      @Autowired protected void setFlowUiComponentProperties(FlowUiComponentProperties flowUiComponentProperties)
    • setScreenNavigators

      @Autowired public void setScreenNavigators(ScreenNavigators screenNavigators)
    • setAccessManager

      @Autowired public void setAccessManager(AccessManager accessManager)
    • setDialogWindowBuilders

      @Autowired public void setDialogWindowBuilders(DialogWindowBuilders dialogWindowBuilders)
    • isPermitted

      protected boolean isPermitted()
      Overrides:
      isPermitted in class SecuredBaseAction
    • execute

      public void execute()
      Executes the action.
      Specified by:
      execute in interface ExecutableAction
    • openDialog

      protected void openDialog()
    • withScreenId

      public CreateAction<E> withScreenId(@Nullable String screenId)
      See Also:
    • withScreenClass

      public CreateAction<E> withScreenClass(@Nullable Class<? extends Screen> screenClass)
      See Also:
    • withRouteParameters

      public CreateAction<E> withRouteParameters(@Nullable com.vaadin.flow.router.RouteParameters routeParameters)
      See Also:
    • withQueryParameters

      public CreateAction<E> withQueryParameters(@Nullable com.vaadin.flow.router.QueryParameters queryParameters)
      See Also:
    • withOpenMode

      public CreateAction<E> withOpenMode(@Nullable OpenMode openMode)
      See Also:
    • withAfterCloseHandler

      public <S extends Screen<?>> CreateAction<E> withAfterCloseHandler(@Nullable Consumer<DialogWindow.AfterCloseEvent<S>> afterCloseHandler)
      See Also:
    • withAfterCommitHandler

      public CreateAction<E> withAfterCommitHandler(@Nullable Consumer<E> afterCommitHandler)
      See Also:
    • withTransformation

      public CreateAction<E> withTransformation(@Nullable Function<E,E> transformation)
      See Also:
    • withInitializer

      public CreateAction<E> withInitializer(@Nullable Consumer<E> initializer)
      See Also:
    • withNewEntitySupplier

      public CreateAction<E> withNewEntitySupplier(@Nullable Supplier<E> newEntitySupplier)
      See Also: