Show TOC Start of Content Area

Object documentation Label  Locate the document in its SAP Library structure

Definition

A multi line region for displaying text. Text in the component is restricted to a single font, size and style unless set with HTML commands.

The label control works similar to textView control. In addition a label has an associated component like an inputField or listBox. The label control can be for client side eventing. See the EventValidationComponent description for more details.

·        design

Defines the appearance of the label. The CSS controls how the different options are rendered. The following description is based on the standard CSS delivered.

¡        LABEL

Text size and attributes STANDARD

¡        LABELSMALL

Text size -2 in comparison to STANDARD

·        enabled - inherited from EventValidationComponent.

A boolean value that enables (=true) or disables (=false) the label control. A disabled label has a different text color to show the user that it is disabled.

·        encode

A boolean value that defines how the label text is interpreted. HTML text formatting commands (for example, <h1>, <i> etc.) can be used to change the display of the text. If there are no formatting commands in the text string, the encode attribute has no effect.

Example:

text="<h1><i>Important</i></h1>"

encode = "false"     Browser output: This graphic is explained in the accompanying text

the text string is rendered by interpreting the formatting commands.

 

encode = "true"      Browser output: This graphic is explained in the accompanying text

the formatting commands are displayed and not interpreted.

 

·        hasDesignBar

Enables or disables a design bar around the label.

·        id

Identification name of the label.

·        jsObjectNeeded - inherited from Component.

A boolean value that defines if a JavaScript object has to be generated for the inputField component.

·        labelFor

Identification name of the next component, which is associated with the label.

·        required

A boolean value. If set to "true" a character (for example, an asterisk (*) in red color) defined by the style sheet is placed at the end of the text string. This is a common method to indicate that input is required. See also inputField.

·        text

Defines the string of text displayed. See 'encode' for a formatting example with embedded HTML commands.

·        tooltip

Defines the hint of the label which is displayed as the mouse cursor passes over the label, or as the mouse button is pressed but not released.

·        valid

Defines the status of the associated input field.

·        width

Defines the width of the label. The width shows only effect when the 'wrapping' attribute is set to "true". Otherwise the width and layout follows the HTML commands in the text string.

·        wrapping

A boolean value. If set to "true" the text is word wrapped at the set 'width' or - if no 'width' is set - at the form width.

 

Attributes

M

Values

Usage

design

 

LABEL
LABELSMALL

Taglib
design="LABEL"

Classlib
setDesign (TextViewDesign.LABEL)

enabled

 

FALSE
TRUE (d)

Taglib
enabled="FALSE"

Classlib
setEnabled(false)

encode

 

FALSE
TRUE (d)

Taglib
encode="FALSE"

Classlib
setEncode(false)

hasDesignBar

 

FALSE (d)
TRUE

Taglib
No tag available

Classlib
setHasDesignBar(false)

id

*

String (cs)

Taglib
id="Intro_text"

Classlib
setId("Intro_text")

jsObjectNeeded**

 

FALSE (d)
TRUE

Taglib
jsObjectNeeded="TRUE"

Classlib
setJsObjectNeeded(true)

labelFor

*

String (cs)

Taglib
labelFor="id_inputField"

Classlib
setLabelFor("id_inputField")

required

 

FALSE (d)
TRUE

Taglib
required="TRUE"

Classlib
setRequired(true)

text

 

String

Taglib
text="Your name please"

Classlib
setText("Your name please")

tooltip

 

String

Taglib
tooltip="Name required"

Classlib
setTooltip("Name required")

valid

 

FALSE
TRUE (d)

Taglib
No tag available

Classlib
setValid(false)

width

 

Unit (100%)

Taglib
width="300"

Classlib
setWidth("300")

wrapping

 

FALSE (d)
TRUE

Taglib
wrapping="TRUE"

Classlib
setWrapping(true)

* Method is inherited from the EventValidationComponent component.

** Method is inherited from the Component component.

 

See the JavaScript API description for details how to access the component in JavaScript.

 

Example

using the taglib

 <hbj:label 
    id=
"label_InputName" 
    
required="TRUE" 
    
text="ZIP Code" 
    
design="LABEL" 
    
labelFor="InputName" 
    
/>

 <hbj:inputField 
    id=
"InputName" 
    
type="string" 
    
maxlength="100" 
    
/>

 

using the classlib

    Form form = (Form) this.getForm();
    InputField input = 
new InputField("InputName");
    input.setType(DataType.STRING);
    input.setMaxlength(100);
    Label label = 
new Label("label_InputName");
    label.setRequired(
true);
    label.setText(
"ZIP Code");
    
label.setDesign(TextViewDesign.LABEL);
    label.setLabelFor(input);
    form.addComponent(label);
    form.addComponent(input);

 

Result

This graphic is explained in the accompanying text

 

 

End of Content Area