public class EntitySelectModel<T extends ITransferableEntity> extends AMessaging implements IEntitySelectModel<T>
Modifier and Type | Field and Description |
---|---|
protected Class<T> |
entityClass |
protected T |
selected |
Constructor and Description |
---|
EntitySelectModel(Class<T> entityClass) |
Modifier and Type | Method and Description |
---|---|
T |
addNew()
Sets the currently selected model to a new model.
|
protected void |
create() |
String |
delete()
Do not override this method, but only
delete(String) . |
String |
delete(String targetView)
Deletes the currently selected model from the database.
|
protected IEntityContext |
ec() |
protected IGenericDao<T> |
getDao() |
protected T |
getNew() |
T |
getSelected() |
protected boolean |
isDetached(de.xima.cmn.dao.interfaces.IEntity<Long> entity) |
boolean |
isNew() |
void |
loadLazyData()
Can be overriden to initialize lazily loaded fields on the entity.
|
protected String |
redirect(String targetView) |
String |
save()
Do not override this method, but only
save(String, boolean, boolean) . |
String |
save(String targetView)
Do not override this method, but only
save(String, boolean, boolean) . |
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.
|
protected void |
update() |
void |
updateSelected()
Rereads the currently model from the database, discarding any local, unsaved changes.
|
addErrorMsg, addErrorMsg, addErrorMsg, addErrorMsg, addErrorMsg, addErrorMsg, addErrorMsgFromString, addErrorMsgFromString, addErrorMsgToComponent, addErrorMsgToComponent, addErrorMsgToComponent, addErrorMsgToComponent, addErrorMsgToComponent, addErrorMsgToComponent, addInfoMsg, addInfoMsg, addInfoMsg, addInfoMsg, addInfoMsgFromString, addInfoMsgFromString, addInfoMsgToComponent, addInfoMsgToComponent, addInfoMsgToComponent, addInfoMsgToComponent, addMsg, addMsg, addMsg, addMsg, addMsgs, addMsgToComponent, addMsgToComponent, addWarnMsg, addWarnMsg, addWarnMsg, addWarnMsg, addWarnMsgFromString, addWarnMsgFromString, addWarnMsgToComponent, addWarnMsgToComponent, addWarnMsgToComponent, addWarnMsgToComponent, cleanErrorMsg, getErrorMessage, getNewErrorMsg, getNewErrorMsg, getNewErrorMsg, getNewInfoMsg, getNewInfoMsg, getNewMsg, getNewWarnMsg, getNewWarnMsg
protected final Class<T extends ITransferableEntity> entityClass
protected T extends ITransferableEntity selected
public T addNew()
IEntitySelectModel
addNew
in interface IEntitySelectModel<T extends ITransferableEntity>
public final String save()
save(String, boolean, boolean)
. Saves the currently selected model to the database. If it IEntitySelectModel.isNew()
, creates a new entry in the database,
otherwise updates the existing entry.save
in interface IEntitySelectModel<T extends ITransferableEntity>
public final String save(String targetView)
save(String, boolean, boolean)
. 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.save
in interface IEntitySelectModel<T extends ITransferableEntity>
targetView
- If given, performs a redirect to this view if the action succeeds. Must be a name of
Enum.name()
, or a relative link.public String save(String targetView, boolean addSuccessMessage, boolean addErrorMessage)
IEntitySelectModel
IEntitySelectModel.isNew()
, creates a new entry in the database,
otherwise updates the existing entry. Performs a redirect to the view, if given.save
in interface IEntitySelectModel<T extends ITransferableEntity>
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).public T getSelected()
getSelected
in interface IEntitySelectModel<T extends ITransferableEntity>
public void loadLazyData()
IEntitySelectModel
loadLazyData
in interface IEntitySelectModel<T extends ITransferableEntity>
public void setSelected(T selected)
IEntitySelectModel
IEntitySelectModel.getSelected()
model
may not refer to the same instance as the given model.setSelected
in interface IEntitySelectModel<T extends ITransferableEntity>
selected
- The model to be selected.public boolean setSelectedById(long id)
IEntitySelectModel
setSelectedById
in interface IEntitySelectModel<T extends ITransferableEntity>
id
- ID of the model to be selected, as returned by IEntity.getId()
.public boolean isNew()
isNew
in interface IEntitySelectModel<T extends ITransferableEntity>
public void updateSelected()
IEntitySelectModel
IEntitySelectModel.isNew()
.updateSelected
in interface IEntitySelectModel<T extends ITransferableEntity>
public final String delete()
delete(String)
. Deletes the currently selected model from the database. If the currently selected model IEntitySelectModel.isNew()
, does
nothing.delete
in interface IEntitySelectModel<T extends ITransferableEntity>
public String delete(String targetView)
IEntitySelectModel
IEntitySelectModel.isNew()
, does
nothing.delete
in interface IEntitySelectModel<T extends ITransferableEntity>
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.protected T getNew()
protected void create()
protected void update()
protected IGenericDao<T> getDao()
protected IEntityContext ec()
protected boolean isDetached(de.xima.cmn.dao.interfaces.IEntity<Long> entity)
Copyright © 2020 XIMA MEDIA GmbH. All rights reserved.