Package de.xima.fc.gui.bean
Class SelectionBean
-
- All Implemented Interfaces:
Serializable
@Named @SessionScoped public class SelectionBean extends AJSFContext
This bean stores the currently selected item for each page/view throughout the session. It keeps a map between the selection key and the selected value. The selected key should be generated in a way that is unique. Currently, we only store the selected entity of various list views in the application, eg./user/ldapgroup
or/system/client
.- Author:
- XIMA MEDIA GmbH
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.xima.fc.gui.common.utils.msg.AJSFContext
AJSFContext.RedirectOptions, AJSFContext.RedirectOptionsBuilder
-
-
Constructor Summary
Constructors Constructor Description SelectionBean()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
createKeyForCurrentView(EEntityKeySelectionType keyType, Class<?> objectClass)
String
createKeyForCurrentView(EEntityKeySelectionType keyType, String additionalKey)
<T,S>
Optional<S>getSelectedAs(String key, Function<String,S> backConverter)
Optional<Long>
getSelectedAsLong(String key)
Optional<String>
getSelectedAsString(String key)
void
store(String key, de.xima.cmn.dao.interfaces.IEntity<?> valueEntity)
Stores the given value for the given key.void
store(String key, Long id)
Stores the given value for the given key.void
store(String selectionKey, String selectionValue)
Associates the given value to the given key for later retrieval.void
storeEntityIdFromUrl(EEntityKeySelectionType keyType, String entityClass)
Can be used to select an entity by a URL parameter.void
storeEntityIdFromUrlClient(String entityClass)
void
storeEntityIdFromUrlProject(String entityClass)
void
storeEntityIdFromUrlSystem(String entityClass)
-
Methods inherited from class de.xima.fc.gui.common.utils.msg.AJSFContext
destroySessionBean, encodeURL, findBean, findBean, findBean, findBean, findBean, findBean, findBean, findCurrentView, findUserContext, getBeanName, getBeanName, getContext, getCurrentViewBean, getLocaleBean, getRequest, getResponse, getSession, getSession, getSessionAttribute, isMasterServerContext, loadLazy, redirect, redirect, redirect, redirect, redirectToDashboard, redirectToDashboard, setLocaleBean, setSessionAttribute, uc
-
Methods inherited from class de.xima.fc.gui.common.utils.msg.MessageUtils
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
-
-
-
-
Method Detail
-
storeEntityIdFromUrlSystem
public void storeEntityIdFromUrlSystem(String entityClass)
-
storeEntityIdFromUrlClient
public void storeEntityIdFromUrlClient(String entityClass)
-
storeEntityIdFromUrlProject
public void storeEntityIdFromUrlProject(String entityClass)
-
storeEntityIdFromUrl
public void storeEntityIdFromUrl(EEntityKeySelectionType keyType, String entityClass)
Can be used to select an entity by a URL parameter. May be called from an xhtml page viaf:viewAction
. Reads the ID from the URL parameter "preselect" and stores that selection.
-
store
public void store(String selectionKey, String selectionValue)
Associates the given value to the given key for later retrieval.- Parameters:
selectionKey
- Key at which to the value.selectionValue
- Value to store.
-
store
public void store(String key, de.xima.cmn.dao.interfaces.IEntity<?> valueEntity)
Stores the given value for the given key.- Parameters:
key
- Key at which to store the value.valueEntity
- Value to store. This stores the ID of the given entity.
-
store
public void store(String key, Long id)
Stores the given value for the given key.- Parameters:
key
- Key at which to store the value.id
- ID to store.
-
getSelectedAs
public <T,S> Optional<S> getSelectedAs(String key, Function<String,S> backConverter)
- Parameters:
key
- Key for which to retrieve the stored value.backConverter
- Some way of converting the stored string value to another type.- Returns:
- The stored value for the given key, converted to the desired type.
-
getSelectedAsLong
public Optional<Long> getSelectedAsLong(String key)
- Parameters:
key
- Key for which to retrieve the stored value.- Returns:
- The stored long for the given key, empty if none is found.
-
getSelectedAsString
public Optional<String> getSelectedAsString(String key)
- Parameters:
key
- Key for which to retrieve the stored value.- Returns:
- The value for the given key, empty if none is found.
-
createKeyForCurrentView
public String createKeyForCurrentView(EEntityKeySelectionType keyType, Class<?> objectClass)
- Parameters:
keyType
- Type of the key, ie. whether the key uses the client and current project.objectClass
- An additional identifier to be included in the key.- Returns:
- The selection key for the current view. It consists of the
EViews
, the client (null
for sadmin) and the current project (null
if the view is not project-specific).
-
createKeyForCurrentView
public String createKeyForCurrentView(EEntityKeySelectionType keyType, String additionalKey)
- Parameters:
keyType
- Type of the key, ie. whether the key uses the client and current project.additionalKey
- An additional identifier to be included in the key.- Returns:
- The selection key for the current view. It consists of the
EViews
, the client (null
for sadmin) and the current project (null
if the view is not project-specific).
-
-