Class EntitySelectModel<T extends ITransferableEntity>

    • Constructor Detail

      • EntitySelectModel

        public EntitySelectModel​(Class<T> entityClass)
    • Method Detail

      • addNew

        public T addNew()
        Description copied from interface: IEntitySelectModel
        Sets the currently selected model to a new model. A new model is not yet persisted in the database and exists only in memory.
        Specified by:
        addNew in interface IEntitySelectModel<T extends ITransferableEntity>
        Returns:
        The newly created entity.
      • save

        public final String save​(String targetView)
        Description copied from interface: IEntitySelectModel
        Saves the currently selected model to the database. If it IEntitySelectModel.isNew(), creates a new entry in the database, otherwise updates the existing entry. Performs a redirect to the view, if given.
        Specified by:
        save in interface IEntitySelectModel<T extends ITransferableEntity>
        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.
      • save

        @Deprecated
        public String save​(String targetView,
                           boolean addSuccessMessage,
                           boolean addErrorMessage)
        Deprecated.
        Description copied from interface: IEntitySelectModel
        Saves the currently selected model to the database. If it IEntitySelectModel.isNew(), creates a new entry in the database, otherwise updates the existing entry. Performs a redirect to the view, if given.
        Specified by:
        save in interface IEntitySelectModel<T extends ITransferableEntity>
        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.
        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).
        Returns:
        Outcome for the redirection.
      • setSelected

        public void setSelected​(T selected)
        Description copied from interface: IEntitySelectModel
        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 IEntitySelectModel.getSelected() model may not refer to the same instance as the given model.
        Specified by:
        setSelected in interface IEntitySelectModel<T extends ITransferableEntity>
        Parameters:
        selected - The model to be selected.
      • setSelectedById

        public boolean setSelectedById​(long id)
        Description copied from interface: IEntitySelectModel
        Sets the selected model to one with the given ID. Reads the model from the database. If no such model exists, does nothing.
        Specified by:
        setSelectedById in interface IEntitySelectModel<T extends ITransferableEntity>
        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.
      • isNew

        public boolean isNew()
        Specified by:
        isNew in interface IEntitySelectModel<T extends ITransferableEntity>
        Returns:
        Whether the currently selected model is new, ie. whether it is persisted in the database or exists only in memory.
      • getNew

        protected T getNew()
      • create

        protected void create()
      • update

        protected void update()
      • isDetached

        protected boolean isDetached​(de.xima.cmn.dao.interfaces.IEntity<Long> entity)