public class

PreferencesBeanImpl

extends AbstractPersistableAppComponent
implements PreferencesBean
java.lang.Object
   ↳ com.microstrategy.utils.serialization.AbstractPersistable
     ↳ com.microstrategy.web.beans.AbstractTransformable
       ↳ com.microstrategy.web.beans.AbstractWebComponent
         ↳ com.microstrategy.web.app.beans.AbstractAppComponent
           ↳ com.microstrategy.web.app.beans.AbstractPersistableAppComponent
             ↳ com.microstrategy.web.app.beans.PreferencesBeanImpl
Known Direct Subclasses

This class is deprecated.
this class will be made non-public

Class Overview

The PreferencesBean is an application level bean that allows end users to set their preferences values. Preferences allows users to customize the application to their own settings.
Preferences are managed by the Preferences class, which is an application level object shared through the appContext class. The PreferencesBean is responsible to present the end-user graphical interface and to handle the events of updating the Preferences values.
Graphically, preferences are grouped based on the level and their usage. Usually for the level, we would have user and administrator preferences. User preferences apply only to the current user and project; administrator preferences are only available to administrator and are applied to all users. On the usage we have groups like General, Grid display, Graph display, etc. We have groups that only apply at the user level, such as History List; we also have groups that only apply at the admin level, such as Login.
The PreferencesBean extends the AppComponent (the base for all Application beans). It provides an initFromXml() method which receives a Node and creates the internal structures for groups and group-sets.
It provides methods to retrieve/set the current group/group-set based on its name.
It has an EventHandler, this event handler is the one responsible to receive the request, update the Preferences or set the current group/group-set from it.
Each group will define the transform it should use to render the preferences. The generateOutput() method (inherited from WebComponent) will check which is the current group, and will call its transform to generate the MarkupOutput.
The class also provides a method to return a MarkupOutput to use to render the groups list.
It implements Persistable. We would use this to save the state of the bean. On the state the current group and group-set are saved.

Summary

Nested Classes
class PreferencesBeanImpl.GroupInfoImpl This class stores the data structure necessary for each group/group-set. 
Constants
String PREFERENCE_CURRENT_GROUP
String PREFERENCE_CURRENT_GROUP_SET
String SEPARATOR
[Expand]
Inherited Constants
From class com.microstrategy.web.app.beans.AbstractPersistableAppComponent
From interface com.microstrategy.utils.serialization.EnumWebPersistableState
From interface com.microstrategy.web.app.beans.AppComponent
From interface com.microstrategy.web.app.beans.PreferencesBean
Fields
protected final String TOKEN_DIV
protected String _applyToAllProjects
protected String _currentGroup
protected String _currentGroupSet
protected String _prevGroupName
[Expand]
Inherited Fields
From class com.microstrategy.web.beans.AbstractWebComponent
From class com.microstrategy.web.beans.AbstractTransformable
Public Methods
void afterUpdate(Map pValues, PreferencesException ex)
void collectData()
Triggers execution to the back end no matter whether it is synchronous or asynchronous.
MarkupOutput generateOutput()
Uses a transform to generate the output.
String getApplyToAllProjects()
Whether to apply the changes to all projects
String getCurrentGroup()
Returns the current group's title.
PreferencesBean.GroupInfo getCurrentGroupInfo()
Returns the current group info structure:
String getCurrentGroupName()
Returns the current group's name.
String getCurrentGroupSet()
Returns which is the current groupset
PreferencesBean.GroupInfo getCurrentGroupSetInfo()
PreferenceLevel getCurrentLevel()
Returns the preferences level of the current preferences group
FeatureInfos getFeatureInfos()
PreferencesBean.GroupInfo getGroupSetInfo(String groupSetName)
String getPrevGroupName()
Returns the previous group's name.
boolean getSettingVisibility(String settingDiv)
Retrieves the boolean value indicating whether we should render the advanced setting Div with Id as setting Div as visible.
Map getTemporalValues()
int getType()
Returns the transformable type as in EnumWebTransformableType.
PreferencesException getValidationErrors()
String getValidationMessage(String name)
Map getValues()
int getXMLStatus()
Returns the EnumRequestStatus status of the bean.
boolean hasValidationErrors()
boolean havePreferencesChanged()
Determines if the user has attemped to change the preferences on a page.
boolean initFromXML(Element root)
Initialize the groups/group-sets from the information of the root
boolean isLoginRequired()
boolean isValidLevel(String level)
Determine if the user has all the privileges required for accessing the preferences under the specified level.
boolean isValidPreference(String name)
MarkupOutput renderGroupsList()
Returns the output to render the groups list.
MarkupOutput renderGroupsList(boolean ignoreCurrent)
Returns the output to render the groups list.
void setApplyToAllProjects(String applyToAllProjects)
Sets whether to apply the changes to all projects
void setBeanContext(BeanContext beanContext)
Extends setBeanContext by auto-initializing this bean.
void setCurrentGroup(String currentGroup)
Sets the current group.
void setCurrentGroupSet(String currentGroupSet)
Sets the current groupset.
void setIsLoginRequired(boolean value)
This method is deprecated. isLoginRequired() can be determined automatically
void setPrevGroupName(String prevGroupName)
Set the previous group's name.
void setSettingVisibility(String settingDiv, String visible)
Set the value in the Hashmap _advSettingsVisibility.
void setXMLStatus(int status)
Set the EnumRequestStatus status of the bean.
void toggleSettingsVisibility(String settingDiv)
Toggle the value in the Hashmap _advSettingsVisibility.
Protected Methods
void doFlatState(FlatStateSerializer serializer, int howMuchState, FlatStateTokenizer tokenizer)
Proceses the save/restore state opperation of the AppComponent
int getVisibleGroupSetCount()
WebEventHandler newDefaultEventHandler()
[Expand]
Inherited Methods
From class com.microstrategy.web.app.beans.AbstractPersistableAppComponent
From class com.microstrategy.web.app.beans.AbstractAppComponent
From class com.microstrategy.web.beans.AbstractWebComponent
From class com.microstrategy.web.beans.AbstractTransformable
From class com.microstrategy.utils.serialization.AbstractPersistable
From class java.lang.Object
From interface com.microstrategy.utils.serialization.Persistable
From interface com.microstrategy.web.app.beans.AppComponent
From interface com.microstrategy.web.app.beans.PreferencesBean
From interface com.microstrategy.web.beans.RequestPersistable
From interface com.microstrategy.web.beans.Transformable
From interface com.microstrategy.web.beans.WebComponent

Constants

protected static final String PREFERENCE_CURRENT_GROUP

Constant Value: "cg"

protected static final String PREFERENCE_CURRENT_GROUP_SET

Constant Value: "cgs"

protected static final String SEPARATOR

Constant Value: ":"

Fields

protected final String TOKEN_DIV

Constant Value: ";"

protected String _applyToAllProjects

protected String _currentGroup

protected String _currentGroupSet

protected String _prevGroupName

Public Methods

public void afterUpdate (Map pValues, PreferencesException ex)

public void collectData ()

Triggers execution to the back end no matter whether it is synchronous or asynchronous. If this method fails to collect data, an exception is raised and saved in a WebBeanError instance.

public MarkupOutput generateOutput ()

Uses a transform to generate the output. The transform used will be the one of the current group.

Returns
  • the dialog for the current Preferences group

public String getApplyToAllProjects ()

Whether to apply the changes to all projects

Returns
  • whether to apply the changes to all projects

public String getCurrentGroup ()

Returns the current group's title.

Returns
  • the current group's title

public PreferencesBean.GroupInfo getCurrentGroupInfo ()

Returns the current group info structure:

Returns
  • the current GroupInfo

public String getCurrentGroupName ()

Returns the current group's name.

Returns
  • the current group's name

public String getCurrentGroupSet ()

Returns which is the current groupset

Returns
  • the current groupSet's title

public PreferencesBean.GroupInfo getCurrentGroupSetInfo ()

Returns
  • a GroupInfo instance corresponding to the current group set selected

public PreferenceLevel getCurrentLevel ()

Returns the preferences level of the current preferences group

Returns
  • the current groupSet's level

public FeatureInfos getFeatureInfos ()

public PreferencesBean.GroupInfo getGroupSetInfo (String groupSetName)

Parameters
groupSetName name of the GroupInfo to search for.
Returns
  • a GroupInfo instance corresponding to the group set name sent in as parameter

public String getPrevGroupName ()

Returns the previous group's name.

Returns
  • the previous group's name

public boolean getSettingVisibility (String settingDiv)

Retrieves the boolean value indicating whether we should render the advanced setting Div with Id as setting Div as visible.

Parameters
settingDiv The Id of the controlled setting Div.
Returns
  • boolean value indicating whether the Div should be visible or not

public Map getTemporalValues ()

public int getType ()

Returns the transformable type as in EnumWebTransformableType.

Returns
  • the transformable type.

public PreferencesException getValidationErrors ()

public String getValidationMessage (String name)

public Map getValues ()

public int getXMLStatus ()

Returns the EnumRequestStatus status of the bean. By default the status of this bean is WebBeanRequestWaitingForUserInput. When the method is invoked with true, then the status changes to be Succesfull.

Returns
  • the EnumRequestStatus of the component.

public boolean hasValidationErrors ()

public boolean havePreferencesChanged ()

Determines if the user has attemped to change the preferences on a page.

Returns
  • true if the user has attemped to change the preferences on a page.

public boolean initFromXML (Element root)

Initialize the groups/group-sets from the information of the root

Parameters
root the XML Element with the structure information
Returns
  • true if the root contained valid information

public boolean isLoginRequired ()

Returns
  • boolean value indicating if the user is required to log out and log back in in order to have the new preference values applied.

public boolean isValidLevel (String level)

Determine if the user has all the privileges required for accessing the preferences under the specified level.

Parameters
level String value with the level the user is trying to access
Returns
  • boolean value indicating if the user is enabled to access this preference level or not.

public boolean isValidPreference (String name)

public MarkupOutput renderGroupsList ()

Returns the output to render the groups list.

Returns
  • the output to display the groups list information.

public MarkupOutput renderGroupsList (boolean ignoreCurrent)

Returns the output to render the groups list.

Parameters
ignoreCurrent ignores which group and group set are currently selected. Displays them all as links
Returns
  • the output to display the groups list information.

public void setApplyToAllProjects (String applyToAllProjects)

Sets whether to apply the changes to all projects

Parameters
applyToAllProjects whether to apply the changes to all projects

public void setBeanContext (BeanContext beanContext)

Extends setBeanContext by auto-initializing this bean. The bean will check in the appContext for a "preferencesGroupsFile" config parameter, if found, it will initialize itself from the path specified.
If this parameter is not present the user will need to manually call initFromXml.
If the user wants to use this bean with a different set of preferences groups, he can call initFromXml and the values will be overwritten.

Parameters
beanContext BeanContext instance to assign to this bean

public void setCurrentGroup (String currentGroup)

Sets the current group. If the new group doesn't exist, it is ignored.

Parameters
currentGroup the name of the new current group

public void setCurrentGroupSet (String currentGroupSet)

Sets the current groupset. If there is no group-set with currentGroupSet the value is ignored.
If the current group exist in the new group-set, the group is kept as current group, if not, the first group of the group-set is used.

Parameters
currentGroupSet the name of the new current group set

public void setIsLoginRequired (boolean value)

This method is deprecated.
isLoginRequired() can be determined automatically

Parameters
value boolean flag indicating if the user is required to log out and log back in in order to have the new preference values applied.

public void setPrevGroupName (String prevGroupName)

Set the previous group's name.

Parameters
prevGroupName the previous group's name

public void setSettingVisibility (String settingDiv, String visible)

Set the value in the Hashmap _advSettingsVisibility.

Parameters
settingDiv The key to the value stored in Hashmap.

public void setXMLStatus (int status)

Set the EnumRequestStatus status of the bean. By default the status of this bean is WebBeanRequestWaitingForUserInput.

Parameters
status int value with the status of this bean

public void toggleSettingsVisibility (String settingDiv)

Toggle the value in the Hashmap _advSettingsVisibility.

Parameters
settingDiv The key to the value stored in Hashmap.

Protected Methods

protected void doFlatState (FlatStateSerializer serializer, int howMuchState, FlatStateTokenizer tokenizer)

Proceses the save/restore state opperation of the AppComponent

Parameters
serializer an instance of the FlatStateSerializer object to use
howMuchState defines how much information needs to be saved
tokenizer an instance of the FlatStateTokenizer object to use

protected int getVisibleGroupSetCount ()

Returns
  • integer value with the count of visible group sets available

protected WebEventHandler newDefaultEventHandler ()