Class WLabel

    • Constructor Detail

      • WLabel

        public WLabel​(String text,
                      char accessKey,
                      WComponent forComponent)
        Creates a new WLabel. Sets the label text, access key and the component that label is for.
        Parameters:
        text - The label text.
        accessKey - The access key for the label.
        forComponent - The component that this label is for.
      • WLabel

        public WLabel​(String text,
                      WComponent forComponent)
        Creates a new WLabel with the specified text and component that the label is for.
        Parameters:
        text - the label text.
        forComponent - the component that this label is for.
      • WLabel

        public WLabel​(String text,
                      char accessKey)
        Creates a new WLabel with the specified text and access key.
        Parameters:
        text - The label text.
        accessKey - The access key for the label's forComponent.
      • WLabel

        public WLabel​(String text)
        Creates a new WLabel with the specified text.
        Parameters:
        text - The label text.
      • WLabel

        public WLabel()
        Creates an empty WLabel.
    • Method Detail

      • getText

        public String getText()
        Returns:
        the label text.
      • setText

        public void setText​(String text,
                            Serializable... args)
        Sets the label's text.
        Parameters:
        text - the label text, using MessageFormat syntax.
        args - optional arguments for the message format string.
      • setHint

        public void setHint​(String hint,
                            Serializable... args)
        Sets the label "hint" text, which can be used to provide additional information to the user.
        Parameters:
        hint - the hint text, using MessageFormat syntax.
        args - optional arguments for the message format string.
      • getHint

        public String getHint()
        Returns:
        the label hint text.
      • setForComponent

        public void setForComponent​(WComponent forComponent)
        Sets the component that this label is associated with.
        Parameters:
        forComponent - the associated component.
      • getForComponent

        public WComponent getForComponent()
        Returns:
        the component that this label is associated with.
      • getLabelFor

        public String getLabelFor()
        Returns:
        the id of the component that this label is for.
      • setAccessKey

        public void setAccessKey​(char accessKey)
        Set the key (in combination with Alt) that should give focus to this label.

        The action that occurs when the label is focussed depends on the type of component this label is for (the forComponent). For example, WTextField will focus the cursor in the text input, WCheckBox will toggle the check box selection. Access keys are not case sensitive.

        Note: Setting the access key also sets the shared title of the component to indicate the access key combination.

        Specified by:
        setAccessKey in interface AccessKeyable
        Parameters:
        accessKey - The key (in combination with the Alt key) that activates this label.
        Since:
        1.0.0
      • getAccessKey

        public char getAccessKey()
        Specified by:
        getAccessKey in interface AccessKeyable
        Returns:
        the component's access key.
      • isEncodeText

        public boolean isEncodeText()
        Indicates whether the heading text needs to be encoded.
        Returns:
        true if the text needs to be encoded, false if not.
      • setEncodeText

        public void setEncodeText​(boolean encodeText)

        Sets whether the heading text needs to be encoded.

        When setting encodeText to false, it then becomes the responsibility of the application to ensure that the text does not contain any characters which need to be escaped.

        Parameters:
        encodeText - true if the text needs to be encode, false if not.
      • 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.
      • setSanitizeOnOutput

        public void setSanitizeOnOutput​(boolean sanitize)
        Pass true if you need to run the HTML sanitizer on any output. This is only needed if the text is not encoded as other cases the output will be XML encoded.
        Parameters:
        sanitize - true if output sanitization is required.
      • isSanitizeOnOutput

        public boolean isSanitizeOnOutput()
        Returns:
        true if this text area is to be sanitized on output.
      • sanitizeOutputText

        protected String sanitizeOutputText​(String text)
        Parameters:
        text - the output text to sanitize
        Returns:
        the sanitized text
      • getComponentModel

        protected WLabel.LabelModel 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 WLabel.LabelModel 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