Class AbstractWebComponent

    • Field Detail

      • _hasJustOpened

        protected boolean _hasJustOpened
        Since:
        MicroStrategy Web 8.1.1
    • Constructor Detail

      • AbstractWebComponent

        public AbstractWebComponent()
        Default constructor, setting the component name to 'wc' followed a unique id.
      • AbstractWebComponent

        protected AbstractWebComponent​(boolean needEventHandler)
        Since:
        MicroStrategy Web 9.0.0
    • Method Detail

      • getName

        public java.lang.String getName()
        Returns the name of the current component.
        Specified by:
        getName in interface WebComponent
        Returns:
        the name of this component.
      • collectData

        public void collectData()
                         throws WebBeanException
        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.
        Specified by:
        collectData in interface WebComponent
        Throws:
        WebBeanException - thrown if there is any exception
      • setName

        public void setName​(java.lang.String name)
        Sets the name for the current component.
        Specified by:
        setName in interface WebComponent
        Parameters:
        name - the name of the current component.
      • getParent

        public WebComponent getParent()
        Returns the parent component of this component.
        Specified by:
        getParent in interface WebComponent
        Returns:
        the parent component.
      • setParent

        public void setParent​(WebComponent parentComponent)
        Sets the parent component for the current component
        Specified by:
        setParent in interface WebComponent
        Parameters:
        parentComponent - the parent component.
      • setBeanContext

        public void setBeanContext​(BeanContext beanContext,
                                   boolean forceUpdateChildren)
        Description copied from interface: WebComponent
        Sets an instance of BeanContext on the current WebBean.
        Specified by:
        setBeanContext in interface WebComponent
        Parameters:
        beanContext - the BeanContext instance to set.
        forceUpdateChildren - if true, the same context is set on the bean's children, if false, the context is set only if a child bean's context is empty
        Since:
        MicroStrategy Web 9.0.0
      • setTargetBeanPath

        public void setTargetBeanPath​(java.lang.String beanName)
        Define the base bean for this instance.
        Specified by:
        setTargetBeanPath in interface WebComponent
        Parameters:
        beanName - String with the name of the bean (with path information if necessary) to be set as the base bean for this instance.
        Since:
        MicroStrategy Web 9.0.0
      • getTargetBeanPath

        public java.lang.String getTargetBeanPath()
        Specified by:
        getTargetBeanPath in interface WebComponent
        Returns:
        a String value with the name of the bean defined to be associated with this instance, if any.
        Since:
        MicroStrategy Web 9.0.0
      • setTargetBean

        public void setTargetBean​(WebComponent bean)
        Set the target bean that will be associated with this instance.
        Specified by:
        setTargetBean in interface WebComponent
        Parameters:
        bean - WebComponent instance to be associated with this bean.
        Since:
        MicroStrategy Web 9.0.0
      • isBeanContextEmpty

        public boolean isBeanContextEmpty()
        Description copied from interface: WebComponent
        Verifies if a bean context exists for the current WebComponent. This method exists because getBeanContext will automatically create a default bean context. Hence we cannot getBeanContext check if it is null
        Specified by:
        isBeanContextEmpty in interface WebComponent
        Since:
        MicroStrategy Web 9.0.0
        See Also:
        WebComponent.isBeanContextEmpty()
      • getRoot

        public WebComponent getRoot()
        Returns the root component reachable from the current component. This method returns itself if it does not have any parent.
        Specified by:
        getRoot in interface WebComponent
        Returns:
        the root component; itself if there is not parent.
      • getPath

        public java.lang.String getPath()
        Returns the path, starting from the root component to this component. The path is reprensented by component names and separated by the character dot.
        Specified by:
        getPath in interface WebComponent
        Returns:
        the path to the current component, reachable from the root component.
      • getWebEvent

        public WebEvent getWebEvent​(int eventID)
        Returns the WebEvent denoted by the event ID. This method queries the current component first, and then turns to ask for its parent component if the current component does not support the specified event, until it reaches the root component.
        Specified by:
        getWebEvent in interface WebComponent
        Parameters:
        eventID - the event ID associated with a WebEvent.
        Returns:
        a WebEvent denoted by the event ID. null if there is no such an event.
      • getWebEvent

        public WebEvent getWebEvent​(int eventID,
                                    boolean recurse)
        Returns the WebEvent denoted by the event ID. This method queries the current component first, and then turns to ask for its parent component if the current component does not support the specified event, until it reaches the root component. If the event is still not found and the parameter recurse is true, then it starts to search the whole hierarchy in depth-first pattern.
        Specified by:
        getWebEvent in interface WebComponent
        Parameters:
        eventID - the event id to search.
        recurse - true if the search is recursive.
        Returns:
        the specified WebEvent; null if there is no such an event existing.
      • setWebEventHandler

        public void setWebEventHandler​(WebEventHandler eventHandler)
        Associate with this component a WebEventHandler instance.

        A WebComponent has one to one relationship with a WebEventHandler instance. This method first removes any existing handler associated with this component, and then sets the new one on it.

        This method calls the method WebEventHandler.setWebComponent(com.microstrategy.web.beans.WebComponent). Therefore, the WebEventHandler implementator should be careful to avoid cyclic reference to each other between this component and the event handler.

        Specified by:
        setWebEventHandler in interface WebComponent
        Parameters:
        eventHandler - the WebEventHandler instance to set.
      • handleRequest

        public boolean handleRequest​(RequestKeys keys)
                              throws WebException
        Handles the request specified by the RequestKeys instance. The RequestKeys object might contain all information sent from the Web browser along with any cookies, session variables, etc. Most importantly, it contains WebEvent related information. If this instance in the namespace of the src request key attribute, it will forward the request to its associated event handler.
        Specified by:
        handleRequest in interface WebComponent
        Parameters:
        keys - the RequestKeys object.
        Returns:
        true if the request is successfully handled; false if the request or event is not supported.
        Throws:
        WebException - thrown if there is any error occurred when handling the request.
      • getChildCount

        public int getChildCount()
        Returns the total number of child component in the current WebComponent.
        Specified by:
        getChildCount in interface WebComponent
        Returns:
        the number of children.
      • addStateInfo

        protected void addStateInfo​(ParameterBuilder paramBldr,
                                    int howMuchState)
        Since:
        MicroStrategy Web 9.0.0
      • addChildStateInfo

        public void addChildStateInfo​(ParameterBuilder paramBldr,
                                      java.lang.String state,
                                      int howMuchState)
        Adds children state information into an existing ParameterBuilder instance. It is up to the supplied ParameterBuilder to determine how this information is serialized.
        Parameters:
        paramBldr - The ParameterBuilder instance which has child state information added to it.
        state - The actual state string to add for this component.
        howMuchState - The amount of state to add for each child component. to return from its children.
        Since:
        MicroStrategy Web 8.0.0
      • addChildStateInfo

        public void addChildStateInfo​(ParameterBuilder paramBldr,
                                      java.lang.String state)
        Since:
        MicroStrategy Web 9.0.0
      • getChildByType

        public WebComponent getChildByType​(int childType)
        Returns the child WebComponent instance specified by the type.
        Specified by:
        getChildByType in interface WebComponent
        Parameters:
        childType - the childType mapped to the WebComponent child type.
        Returns:
        the child WebComponent instance; null if the childType is not mapped to any child WebComponent.
      • getChildByClass

        public WebComponent getChildByClass​(java.lang.Class classInstance)
        Returns the child WebComponent instance specified by the class.
        Specified by:
        getChildByClass in interface WebComponent
        Parameters:
        classInstance - the classInstance mapped to the WebComponent class instance.
        Returns:
        the child WebComponent instance; null if the classInstance is not mapped to any child WebComponent.
        Since:
        MicroStrategy Web 8.0.0
      • getChildrenByClass

        public void getChildrenByClass​(java.lang.Class classInstance,
                                       HashList retList,
                                       boolean recursive)
        Returns the child WebComponent instance specified by the class. If recursive is true, recursively searchs for children components.
        Specified by:
        getChildrenByClass in interface WebComponent
        Parameters:
        classInstance - the Class instance mapped to the WebComponent class instance.
        retList - a HashList to store the result
        recursive - true means searching recursively.
        Since:
        MicroStrategy Web 8.0.0
      • getChild

        public WebComponent getChild​(java.lang.String path)
        Returns the bottom child component at the specified path. The path starts from the root WebComponent all the way down the bottom child in the hierarchy. Each component appearing in the path is represented by its name and all components are separated by the character dot. For example, the path key1.key2.key3 says that the root component is key1 and component key3 is one of the grand children of key1.
        Specified by:
        getChild in interface WebComponent
        Parameters:
        path - the path to the child WebComponent.
        Returns:
        the bottom child component along the path; null if the child is not found.
      • getChild

        public WebComponent getChild​(int index)
        Returns the child WebComponent specified by the index.
        Specified by:
        getChild in interface WebComponent
        Parameters:
        index - position of the child component in the current component.
        Returns:
        the child component at the specified position; null if the index is out of bounds.
      • searchChild

        public WebComponent searchChild​(java.lang.String key)
        Searches whole hierarchy rooted at the current component for the child component specified the key and returns the search result. The search starts with the immediate children of the current component, if not found, then it propagate to its grand children in depth-first manner.
        Specified by:
        searchChild in interface WebComponent
        Parameters:
        key - the key mapped to the child component to be searched.
        Returns:
        the child WebComponent; null if there is no such a component existing in the hierarchy.
      • addChild

        public void addChild​(java.lang.String key,
                             WebComponent child)
        Adds a child component to the current WebComponent. This call invalidates the cached states.
        Specified by:
        addChild in interface WebComponent
        Parameters:
        key - the key mapped to the child component.
        child - the child component to add.
      • removeChild

        public WebComponent removeChild​(java.lang.String key)
        Removes the specified child component from the current component. This call invalidates the cached states.
        Specified by:
        removeChild in interface WebComponent
        Parameters:
        key - the key mapped to the child component.
        Returns:
        the removed child component.
      • removeChild

        public WebComponent removeChild​(WebComponent component)
        Removes the specified child component from the current component.
        Specified by:
        removeChild in interface WebComponent
        Parameters:
        component - the child component to be removed.
        Returns:
        the removed child component.
      • clearChildren

        public void clearChildren()
        Removes all the child component instances from this component. This call invalidates the cached states.
      • getPersistMode

        public int getPersistMode()
        Returns the persist flag (EnumBeanPersistMode) of the current WebComponent.
        Specified by:
        getPersistMode in interface WebComponent
        Returns:
        the persist flag of the current WebComponent.
      • getMaximumStateLevel

        public int getMaximumStateLevel()
        Returns either the default state level of the current component or the maximum state level among the current component and its child components, whichever is greater.
        Specified by:
        getMaximumStateLevel in interface WebComponent
        Returns:
        the maximum state level.
      • getDefaultStateLevel

        public int getDefaultStateLevel()
        Returns the default state level. If not set, the default state level is EnumWebPersistableState.MINIMAL_STATE_INFO.
        Specified by:
        getDefaultStateLevel in interface WebComponent
        Returns:
        the defautl state level.
      • setDefaultStateLevel

        public void setDefaultStateLevel​(int stateLevel)
        Set the default state level. If not set, the default state level is EnumWebPersistableState.MINIMAL_STATE_INFO.
        Specified by:
        setDefaultStateLevel in interface WebComponent
        Parameters:
        stateLevel -
      • invalidateChildrenState

        public void invalidateChildrenState()
        Invalidates the cached state of a component and its children.
        Specified by:
        invalidateChildrenState in interface WebComponent
      • saveXMLState

        protected void saveXMLState​(java.lang.StringBuffer buf,
                                    int howMuchState,
                                    int stateFlag)
        Saves the component state in the provided StringBuffer
        Overrides:
        saveXMLState in class AbstractPersistable
        Parameters:
        buf - a StringBuffer object
        howMuchState - how much state to save (EnumWebPersistableState)
        Since:
        MicroStrategy Web 9.0.0
      • saveXMLState

        protected void saveXMLState​(XMLStateSerializer builder,
                                    int howMuchState)
        Saves the component state
        Parameters:
        builder - a XMLStateSerializer object
        howMuchState - how much state to save (EnumWebPersistableState)
      • saveXMLState

        protected void saveXMLState​(XMLStateSerializer builder,
                                    int howMuchState,
                                    int stateFlag)
        Saves the component state
        Parameters:
        builder - a XMLStateSerializer object
        howMuchState - how much state to save (EnumWebPersistableState)
        stateFlag - TODO
        Since:
        MicroStrategy Web 9.0.0
      • restoreStateFromRequest

        public boolean restoreStateFromRequest​(RequestKeys rk)
        Restores this component from the saved state keyed by this component's name in the RequestKeys object. When restoring its own state, this component may delegate restoration to its child components. This method is equivalent to call restoreStateFromRequest(rk, getName()).
        Parameters:
        rk - the RequestKeys object containing the saved state of this component.
        Returns:
        true if restoration is successful; false otherwise.
      • restoreStateFromRequest

        public boolean restoreStateFromRequest​(RequestKeys rk,
                                               java.lang.String keyName)
        Restores this component from the saved state keyed by keyName in the RequestKeys object. When restoring its own state, this component may delegate restoration to its child components.
        Parameters:
        rk - the RequestKeys object containing the saved state of this component.
        keyName - the key whose corresponding value contains the saved state of this component.
        Returns:
        true if restoration is successful; false otherwise.
      • restoreState

        public boolean restoreState​(java.lang.String state)
        Description copied from interface: Persistable
        Restores a component based on its saved state.
        Specified by:
        restoreState in interface Persistable
        Overrides:
        restoreState in class AbstractPersistable
        Parameters:
        state - the state of a component
        Returns:
        true if restoration succeeds.
        Since:
        MicroStrategy Web 8.0.0
      • isFeatureAvailable

        public boolean isFeatureAvailable​(java.lang.String featureList)

        Verifies if the corresponding feature(s) is accesible based on the properties of this WebComponent.

        This method receives a semi-colon (i.e. FeatureArray.FEATURE_ARRAY_DELIMITER_STRING) separated list of features to validate. Each feature can be prefixed with "!" to indicate the return value should be negated. For example, if the following value is received as argument:

        a;!b;c
        will return true if and only if:
        1. a is available
        2. b is not available
        3. c is available.
        For each feature in the list to be available, this method first will check if its available in the Global Features. If available there, then it will check with its parent WebComponent (if any).
        Specified by:
        isFeatureAvailable in interface WebComponent
        Parameters:
        featureList - a semi-colon separated list of feature ids to check.
        Returns:
        true indicating if the compound feature is accesible or not
      • hasChanged

        public boolean hasChanged()
        Verifies the state of the component has changed
        Specified by:
        hasChanged in interface WebComponent
        Returns:
        true if the component is changed
        Since:
        MicroStrategy Web 8.0.0
      • haveChildrenChanged

        protected boolean haveChildrenChanged()
        Since:
        MicroStrategy Web 9.0.0
      • hasJustOpened

        public boolean hasJustOpened()
        Verifies if the component has just been opened. This would mean that the current event processed would be an event to open this component.
        Specified by:
        hasJustOpened in interface WebComponent
        Returns:
        true if the component has just been opened.
        Since:
        MicroStrategy Web 8.0.0
      • setChanged

        public void setChanged​(boolean value)
        Sets the changed state of the component
        Specified by:
        setChanged in interface WebComponent
        Parameters:
        value - a boolean value indicating whether the component is changed.
        Since:
        MicroStrategy Web 8.0.0
      • setChanged

        public void setChanged​(boolean value,
                               boolean recurse)
        Description copied from interface: WebComponent
        Sets the changed state of the component
        Specified by:
        setChanged in interface WebComponent
        Parameters:
        value - a boolean value indicating whether the component is changed
        recurse - boolean to indicate whether the value needs to be propogated to child components.
        Since:
        MicroStrategy Web 9.0.0
      • setFeaturesManager

        public void setFeaturesManager​(WebFeatures featuresManager)
        Associates a WebFeatures implementation with this WebComponent
        Specified by:
        setFeaturesManager in interface WebComponent
        Parameters:
        featuresManager - a WebFeatures object.
      • getFeaturesManager

        public WebFeatures getFeaturesManager()
        Return the WebFeatures implementation associated with this WebComponent
        Specified by:
        getFeaturesManager in interface WebComponent
        Returns:
        a WebFeatures instance
      • clearStateCache

        protected void clearStateCache​(int howMuchToClear)
        Clears the cached state for the current component only, without touching any child component's state.

        Since typical state usually contains information saved in the minimum state, clearing minimum state should invalidate the cached typical state too, but not vice versa.

        Parameters:
        howMuchToClear - a flag of EnumWebPersistableState indicating how much state to clear.
      • setStateCache

        protected void setStateCache​(int whatState,
                                     java.lang.String stateToSave)
        Caches the state specified by whatState.
        Parameters:
        whatState - a value from the EnumWebPersistableState indicating what state to return.
        stateToSave - the component's state to be cached
      • getCachedState

        protected java.lang.String getCachedState​(int whatState)
        Return the cached state specified by the whatState. Only typical and minimum states are cached.
        Parameters:
        whatState - a value from the EnumWebPersistableState indicating what state to return.
        Returns:
        the cached state. null if the cache is invalid.
      • childValues

        protected java.util.Collection childValues()
        Since:
        MicroStrategy Web 8.1.0
      • setRenderingFilter

        public void setRenderingFilter​(java.util.Set renderingFilter)
        Description copied from interface: WebComponent
        Sets the list of beans to render. The idea here is that, sometimes during an iframe request even though a bean has changed, there might be some beans (e.g. Toolbar) who should'nt need to render themselves just because they have this component as their targetBeanPath. renderingFilter should help control that.
        Specified by:
        setRenderingFilter in interface WebComponent
        Parameters:
        renderingFilter - a Set of Strings representing beanNames
        Since:
        MicroStrategy Web 8.1.0
      • getRenderingFilter

        public java.util.Set getRenderingFilter()
        Description copied from interface: WebComponent
        returns the rendering filter.
        Specified by:
        getRenderingFilter in interface WebComponent
        Returns:
        rendering filter.
        Since:
        MicroStrategy Web 8.1.0
      • prepareForReuse

        public void prepareForReuse()
        Description copied from interface: WebComponent
        If a Web Component instance is going to be reused across different requests, this API serves as a notifier to the component to do the necessary cleanup.
        Specified by:
        prepareForReuse in interface WebComponent
        Since:
        MicroStrategy Web 9.0.0
      • newDefaultEventHandler

        protected WebEventHandler newDefaultEventHandler()
        Since:
        MicroStrategy Web 9.0.0
      • isChangeComparisonFlagSet

        protected boolean isChangeComparisonFlagSet​(int stateFlag)
        Since:
        MicroStrategy Web 9.0.0
      • initBean

        public void initBean()
        Description copied from interface: WebComponent
        Initialize the component after it's created and its properties initialized
        Specified by:
        initBean in interface WebComponent