public class EntityListModel<T extends ITransferableEntity> extends AMessaging implements IEntityListModel<T>
Modifier and Type | Field and Description |
---|---|
protected List<T> |
all |
protected Class<T> |
entityClass |
protected List<T> |
filtered |
protected String |
globalFilter |
protected boolean |
hasAddNewEntity |
protected List<T> |
marked |
protected de.xima.cmn.criteria.QueryCriteriaManager |
qcm |
protected T |
selected |
Constructor and Description |
---|
EntityListModel(Class<T> entityClass,
de.xima.cmn.criteria.QueryCriteriaManager qcm) |
Modifier and Type | Method and Description |
---|---|
void |
addMarked(T entity)
Adds the given entity to the
List of marked entities |
void |
addNew()
Sets the currently selected model to a new model.
|
void |
create() |
String |
delete()
Deletes the currently selected model from the database.
|
String |
delete(String targetView)
Deletes the currently selected model from the database.
|
String |
deleteEntity(String targetView,
T entity)
Same as
IEntityListModel.delete(String) , but takes the model to be deleted as an argument instead of deleting the currently
selected model. |
String |
deleteEntity(T entity)
Same as
IEntityListModel.delete() , but takes the model to be deleted as an argument instead of deleting the currently
selected model. |
void |
deleteMarkedEntities()
Deletes all marked entities
|
IEntityContext |
ec() |
protected List<T> |
fetchAll()
Fetches all available entities.
|
List<T> |
getAll() |
List<T> |
getAllPlusNew() |
IGenericDao<T> |
getDao() |
List<T> |
getFiltered() |
String |
getGlobalFilter() |
List<T> |
getMarked() |
T |
getNew() |
T |
getSelected() |
boolean |
hasEntity() |
protected boolean |
isDetached(de.xima.cmn.dao.interfaces.IEntity<Long> entity) |
boolean |
isEmptyList() |
boolean |
isMarkedDeletable() |
boolean |
isNew() |
void |
loadLazyData()
Can be overriden to initialize lazily loaded fields on the entity.
|
void |
onRowSelect(org.primefaces.event.SelectEvent event) |
void |
onRowSelectCheckbox(org.primefaces.event.SelectEvent event) |
void |
onRowUnselectCheckbox(org.primefaces.event.UnselectEvent event) |
void |
onToggleSelect(org.primefaces.event.ToggleSelectEvent event) |
void |
removeMarked(T entity)
Removes the given entity from the
List of marked entities |
void |
save()
Saves the currently selected model to the database.
|
void |
save(boolean addSuccessMessage,
boolean addErrorMessage) |
protected void |
selectDefault()
Called when no item is selected.
|
void |
setFiltered(List<T> filtered)
Sets the list of filtered models.
|
void |
setGlobalFilter(String globalFilter) |
void |
setHasAddNewEntity(boolean isNewEntity) |
void |
setMarked(List<T> marked)
Sets the list of marked entities
|
void |
setSelected(T selected)
Sets the currently selected model to the given model.
|
void |
setSelectedFromMarked()
If there is exactly one entity marked, makes it the selected one
|
void |
update() |
void |
updateData() |
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
protected boolean hasAddNewEntity
protected final Class<T extends ITransferableEntity> entityClass
protected final de.xima.cmn.criteria.QueryCriteriaManager qcm
protected List<T extends ITransferableEntity> all
protected List<T extends ITransferableEntity> filtered
protected List<T extends ITransferableEntity> marked
protected T extends ITransferableEntity selected
protected String globalFilter
public List<T> getAll()
getAll
in interface IEntityListModel<T extends ITransferableEntity>
IEntityListModel.isNew()
, unsaved model.public List<T> getAllPlusNew()
getAllPlusNew
in interface IEntityListModel<T extends ITransferableEntity>
IEntityListModel.isNew()
, unsaved model, if it exists.public void updateData()
updateData
in interface IUpdatable
protected void selectDefault()
setSelected(ITransferableEntity)
. Defaults to selecting the first item; or a new item if no items exists.
Override for custom behavior.protected List<T> fetchAll()
QueryCriteriaManager
provided in the constructor. Override this for custom logic. If you choose to override
this, you may provide null
for the QueryCriteriaManager
, if you do not call this super method
and do not attempt to use it yourself.public void addNew()
IEntityListModel
addNew
in interface IEntityListModel<T extends ITransferableEntity>
public T getNew()
public void create()
public void update()
public void save(boolean addSuccessMessage, boolean addErrorMessage)
public void save()
IEntityListModel
IEntityListModel.isNew()
, creates a new entry in the database,
otherwise updates the existing entry.save
in interface IEntityListModel<T extends ITransferableEntity>
public T getSelected()
getSelected
in interface IEntityListModel<T extends ITransferableEntity>
public String getGlobalFilter()
public void setGlobalFilter(String globalFilter)
public void loadLazyData()
IEntityListModel
loadLazyData
in interface IEntityListModel<T extends ITransferableEntity>
public void setSelected(T selected)
IEntityListModel
IEntityListModel.getSelected()
model
may not refer to the same instance as the given model.setSelected
in interface IEntityListModel<T extends ITransferableEntity>
selected
- The model to be selected.public void setSelectedFromMarked()
setSelectedFromMarked
in interface IEntityListModel<T extends ITransferableEntity>
public List<T> getFiltered()
getFiltered
in interface IEntityListModel<T extends ITransferableEntity>
IEntityListModel.getAll()
, with some models excluded according to some filter criterion.public void setFiltered(List<T> filtered)
IEntityListModel
IEntityListModel.getAll()
.setFiltered
in interface IEntityListModel<T extends ITransferableEntity>
filtered
- List of filtered models to set.public List<T> getMarked()
getMarked
in interface IEntityListModel<T extends ITransferableEntity>
List
of entities that have been marked (i.e. for further processing)public void setMarked(List<T> marked)
IEntityListModel
setMarked
in interface IEntityListModel<T extends ITransferableEntity>
marked
- List
of entities to be markedpublic void addMarked(T entity)
IEntityListModel
List
of marked entitiesaddMarked
in interface IEntityListModel<T extends ITransferableEntity>
entity
- to be addedpublic void removeMarked(T entity)
IEntityListModel
List
of marked entitiesremoveMarked
in interface IEntityListModel<T extends ITransferableEntity>
entity
- to be removedpublic boolean isNew()
isNew
in interface IEntityListModel<T extends ITransferableEntity>
public void updateSelected()
IEntityListModel
IEntityListModel.isNew()
.updateSelected
in interface IEntityListModel<T extends ITransferableEntity>
public boolean isEmptyList()
isEmptyList
in interface IEntityListModel<T extends ITransferableEntity>
true
iff IEntityListModel.getAll()
is empty.public boolean hasEntity()
hasEntity
in interface IEntityListModel<T extends ITransferableEntity>
true
iff not #IEntityListModel.isEmptyList()
or the currently selected model IEntityListModel.isNew()
.public void setHasAddNewEntity(boolean isNewEntity)
public IGenericDao<T> getDao()
public String delete()
IEntityListModel
IEntityListModel.isNew()
, does
nothing.delete
in interface IEntityListModel<T extends ITransferableEntity>
public String delete(String targetView)
IEntityListModel
IEntityListModel.isNew()
, does
nothing.delete
in interface IEntityListModel<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.public IEntityContext ec()
protected boolean isDetached(de.xima.cmn.dao.interfaces.IEntity<Long> entity)
public String deleteEntity(T entity)
IEntityListModel
IEntityListModel.delete()
, but takes the model to be deleted as an argument instead of deleting the currently
selected model.deleteEntity
in interface IEntityListModel<T extends ITransferableEntity>
entity
- The model to be deleted.public String deleteEntity(String targetView, T entity)
IEntityListModel
IEntityListModel.delete(String)
, but takes the model to be deleted as an argument instead of deleting the currently
selected model.deleteEntity
in interface IEntityListModel<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.entity
- The model to be deleted.public boolean isMarkedDeletable()
isMarkedDeletable
in interface IEntityListModel<T extends ITransferableEntity>
true
iff every single marked entity is deletable. false
otherwisepublic void deleteMarkedEntities()
IEntityListModel
deleteMarkedEntities
in interface IEntityListModel<T extends ITransferableEntity>
public void onRowSelect(org.primefaces.event.SelectEvent event)
onRowSelect
in interface IEntityListModel<T extends ITransferableEntity>
public void onRowSelectCheckbox(org.primefaces.event.SelectEvent event)
onRowSelectCheckbox
in interface IEntityListModel<T extends ITransferableEntity>
public void onRowUnselectCheckbox(org.primefaces.event.UnselectEvent event)
onRowUnselectCheckbox
in interface IEntityListModel<T extends ITransferableEntity>
public void onToggleSelect(org.primefaces.event.ToggleSelectEvent event)
onToggleSelect
in interface IEntityListModel<T extends ITransferableEntity>
Copyright © 2019 XIMA MEDIA GmbH. All rights reserved.