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
    • Constructor Detail

      • SelectionBean

        public SelectionBean()
    • 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 via f: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).