Interface IEntitySelectModel<T extends ITransferableEntity>

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      T addNew()
      Sets the currently selected model to a new model.
      String delete()
      Deletes the currently selected model from the database.
      String delete​(String targetView)
      Deletes the currently selected model from the database.
      T getSelected()  
      boolean isNew()  
      void loadLazyData()
      Can be overriden to initialize lazily loaded fields on the entity.
      String save()
      Saves the currently selected model to the database.
      String save​(String targetView)
      Saves the currently selected model to the database.
      String save​(String targetView, boolean addSuccessMessage, boolean addErrorMessage)
      Saves the currently selected model to the database.
      void setSelected​(T selected)
      Sets the currently selected model to the given model.
      boolean setSelectedById​(long id)
      Sets the selected model to one with the given ID.
      void updateSelected()
      Rereads the currently model from the database, discarding any local, unsaved changes.
    • Method Detail

      • addNew

        T addNew()
        Sets the currently selected model to a new model. A new model is not yet persisted in the database and exists only in memory.
      • delete

        String delete()
        Deletes the currently selected model from the database. If the currently selected model isNew(), does nothing.
        Returns:
        A view ID of the page to show after the model was deleted.
      • delete

        String delete​(String targetView)
        Deletes the currently selected model from the database. If the currently selected model isNew(), does nothing.
        Parameters:
        targetView - The Enum.name() of a view whose view ID is returned after this operation completes successfully. Can also be a relative path, in which case that path is returned.
        Returns:
        A view ID of the page to show after the model was deleted.
      • getSelected

        T getSelected()
        Returns:
        The currently selected model. A new model if none is selected.
      • isNew

        boolean isNew()
        Returns:
        Whether the currently selected model is new, ie. whether it is persisted in the database or exists only in memory.
      • loadLazyData

        void loadLazyData()
        Can be overriden to initialize lazily loaded fields on the entity. By default, does not load any lazy data.
      • save

        String save()
        Saves the currently selected model to the database. If it isNew(), creates a new entry in the database, otherwise updates the existing entry.
        Returns:
        Outcome for the redirection.
      • save

        String save​(String targetView,
                    boolean addSuccessMessage,
                    boolean addErrorMessage)
        Saves the currently selected model to the database. If it isNew(), creates a new entry in the database, otherwise updates the existing entry. Performs a redirect to the view, if given.
        Parameters:
        addSuccessMessage - Whether a success message is added to the faces context (in case of success).
        addErrorMessage - Whether an error message is added to the faces context (in case of an error).
        targetView - If given, performs a redirect to this view if the action succeeds. Must be a name of Enum.name(), or a relative link.
        Returns:
        Outcome for the redirection.
      • save

        String save​(String targetView)
        Saves the currently selected model to the database. If it isNew(), creates a new entry in the database, otherwise updates the existing entry. Performs a redirect to the view, if given.
        Parameters:
        targetView - If given, performs a redirect to this view if the action succeeds. Must be a name of Enum.name(), or a relative link.
        Returns:
        Outcome for the redirection.
      • setSelected

        void setSelected​(T selected)
        Sets the currently selected model to the given model. If the given model exists in the database but is not currently managed by an entity manager, rereads the model from the database. Thus the getSelected() model may not refer to the same instance as the given model.
        Parameters:
        selected - The model to be selected.
      • setSelectedById

        boolean setSelectedById​(long id)
        Sets the selected model to one with the given ID. Reads the model from the database. If no such model exists, does nothing.
        Parameters:
        id - ID of the model to be selected, as returned by IEntity.getId().
        Returns:
        Whether the model could be selected, ie. iff an entity with the given ID exists.
      • updateSelected

        void updateSelected()
        Rereads the currently model from the database, discarding any local, unsaved changes. Does nothing iff the currently selected model isNew().