Class WCollapsible

    • Constructor Detail

      • WCollapsible

        public WCollapsible​(WComponent content,
                            String heading)
        Creates a WCollapsible with the given content and heading.
        Parameters:
        content - the content to display inside the collapsible.
        heading - the collapsible's heading.
      • WCollapsible

        public WCollapsible​(WComponent content,
                            WDecoratedLabel label)
        Creates a WCollapsible with the given content and heading.
        Parameters:
        content - the content to display inside the collapsible.
        label - the collapsible's heading.
      • WCollapsible

        public WCollapsible​(WComponent content,
                            String heading,
                            WCollapsible.CollapsibleMode mode)
        Creates a WCollapsible with the given content and heading.
        Parameters:
        content - the content to display inside the collapsible.
        heading - the collapsible's heading.
        mode - the mode of the collapsible
      • WCollapsible

        public WCollapsible​(WComponent content,
                            WDecoratedLabel label,
                            WCollapsible.CollapsibleMode mode)
        Creates a WCollapsible with the given content and heading.
        Parameters:
        content - the content to display inside the collapsible.
        label - the collapsible's heading.
        mode - the mode of the collapsible
      • WCollapsible

        public WCollapsible​(WComponent content,
                            String heading,
                            WCollapsible.CollapsibleMode mode,
                            CollapsibleGroup group)
        Creates a WCollapsible with the given content, heading and group.
        Parameters:
        content - the content to display inside the collapsible.
        heading - the collapsible's heading.
        mode - the mode of the collapsible
        group - the CollapsibleGroup that this collapsible belongs to.
    • Method Detail

      • setMode

        public void setMode​(WCollapsible.CollapsibleMode mode)
        Sets this WCollapsible's mode of operation. CollapsibleMode.SERVER is mapped to CollapsibleMode.DYNAMIC in order to prevent an a11y issue as per #694.
        Parameters:
        mode - the mode of operation.
      • setMargin

        public void setMargin​(Margin margin)
        Set the margin for the component, or null for no margin.
        Specified by:
        setMargin in interface Marginable
        Parameters:
        margin - the margin for the component
      • getMargin

        public Margin getMargin()
        Get the margin for the component, or null if not set.
        Specified by:
        getMargin in interface Marginable
        Returns:
        the margin for the component, or null if not set
      • isCollapsed

        public boolean isCollapsed()
        Indicates whether the collapsible is collapsed in the given context.
        Returns:
        true if the collapsible is collapsed for the given user, false if expanded.
      • setCollapsed

        public void setCollapsed​(boolean collapsed)
        Sets whether the collapsible is collapsed in the given context.
        Parameters:
        collapsed - true if the collapsible is to be collapsed for the given user, false if expanded.
      • getContent

        public WComponent getContent()
        Returns:
        the content of this collapsible
      • getDecoratedLabel

        public WDecoratedLabel getDecoratedLabel()
        Returns:
        the decorated label that is used to render the collapsible heading.
      • setHeading

        @Deprecated
        public void setHeading​(String heading)
        Deprecated.
        use getDecoratedLabel().setText(String)
        Sets the collapsible's heading for the given context.
        Parameters:
        heading - the heading text to set.
      • getGroupName

        public String getGroupName()
        The group name that this collapsible component belongs to. If it is not part of a group then the name defaults to WComponent.getName().
        Returns:
        the collapsible group name
      • getHeadingLevel

        public HeadingLevel getHeadingLevel()
        Returns:
        the collapsible's heading level
      • setHeadingLevel

        public void setHeadingLevel​(HeadingLevel headingLevel)
        Parameters:
        headingLevel - the collapsible's heading level
      • handleRequest

        public void handleRequest​(Request request)
        Override handleRequest to perform processing necessary for this component. This is used to handle the server-side collapsible mode and to synchronise with the client-side state for the other modes.
        Specified by:
        handleRequest in interface WComponent
        Overrides:
        handleRequest in class AbstractWComponent
        Parameters:
        request - the request being responded to.
      • preparePaintComponent

        protected void preparePaintComponent​(Request request)
        Override preparePaintComponent in order to toggle the visibility of the content, or to register the appropriate ajax operation.
        Overrides:
        preparePaintComponent in class AbstractWComponent
        Parameters:
        request - the request being responded to
      • toString

        public String toString()
        Description copied from class: AbstractWComponent
        Creates a String representation of this component; usually for debugging purposes.
        Overrides:
        toString in class AbstractWComponent
        Returns:
        a String representation of this component, for debugging purposes.
      • getComponentModel

        protected WCollapsible.CollapsibleModel getComponentModel()
        Returns the effective component model for this component. Subclass may override this method to narrow the return type to their specific model type.
        Overrides:
        getComponentModel in class AbstractWComponent
        Returns:
        the effective component model
      • getOrCreateComponentModel

        protected WCollapsible.CollapsibleModel getOrCreateComponentModel()
        Retrieves the model for this component so that it can be modified. If this method is called during request processing, and a session specific model does not yet exist, then a new model is created. Subclasses may override this method to narrow the return type to their specific model type.
        Overrides:
        getOrCreateComponentModel in class AbstractWComponent
        Returns:
        the model for this component