Interface IEntitySelectModel<T extends ITransferableEntity>

Type Parameters:
T - The type of the encapsulated entity.
All Known Implementing Classes:
CurrentProjectBean.EntitySelectModelImpl, EntitySelectModel, ProjectTemplateBean.EntitySelectModelImpl

public interface IEntitySelectModel<T extends ITransferableEntity>
IEntityListModel describes a list of entities of which one can be selected. It is used mainly for views with editable lists of entities. In contrast, this interface is meant for views that only require access to a particular given entity.
Author:
XIMA MEDIA GmbH
  • Method Summary

    Modifier and Type
    Method
    Description
    Sets the currently selected model to a new model.
    Deletes the currently selected model from the database.
    delete(String targetView)
    Deprecated.
    use delete() instead.
     
    boolean
     
    void
    Can be overriden to initialize lazily loaded fields on the entity.
    Saves the currently selected model to the database.
    save(String targetView)
    Deprecated.
    Use save() instead.
    save(String targetView, boolean addSuccessMessage, boolean addErrorMessage)
    Deprecated. 
    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
    Rereads the currently model from the database, discarding any local, unsaved changes.
  • Method Details

    • 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.
      Returns:
      The newly created entity.
    • 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.
    • 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

      @Deprecated String save(String targetView, boolean addSuccessMessage, boolean addErrorMessage)
      Deprecated.
      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.
    • 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().
    • delete

      @Deprecated String delete(String targetView)
      Deprecated.
      use delete() instead.
      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.
    • save

      @Deprecated String save(String targetView)
      Deprecated.
      Use save() instead.
      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.