Show TOC Start of Content Area

Object documentation Checkbox  Locate the document in its SAP Library structure

Definition

A control, consisting of a graphic and associated text, that a user clicks to select or deselect an option. A check mark in the checkBox graphic indicates that the option is selected.

The checkbox control can be for client side eventing. See the EventValidationComponent description for more details.

·        checked

A boolean value that that indicates if a checkBox is selected. "True" shows a check mark in a checkBox and indicates that the checkBox is selected, "false" leaves the checkBox empty and indicates that the checkBox is not selected.

·        enabled - inherited from EventValidationComponent.

A boolean value that defines if the checkBox is click able. If the checkBox is disabled (enabled = false) it is not selectable. A disabled checkBox has a different background color for the checkBox graphic and if the checkBox is checked the a different color for the check mark.

·        encode

A boolean value that defines how the checkBox text is interpreted. HTML text formatting commands (for example, <h1>, <i> etc.) can be used to change the display of the checkBox text. If there are no formatting commands in the checkBox 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.

·        id

Identification name of the checkBox.

·        jsObjectNeeded - inherited from Component.

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

·        labeled

Notify the component that a label has assigned to it. See the HTMLB JavaDoc for more details on the LabeledComponent class.

·        onClick

Defines the event handling method that will be processed when the user clicks on the enabled checkBox. If you do not define a 'onClick' Event the checkBox can be clicked but no event is generated.

·        onClientClick

Defines the JavaScript fragment that is executed when the user clicks on the checkbox. If both events ('onClick' and 'onClientClick') are specified, the 'onClientClick' event handling method is activated first. By default the 'onClick' event handling method is activated afterwards. In the JavaScript fragment you can cancel the activation of the 'onClick' event handling method with the command:

htmlbevent.cancelSubmit=true;

The 'onClientClick' event is useful to pre process the form and only send the form to client if the preprocessing was successful (for example, date validation, valid number format etc.) to save client/server interaction.

·        text

Defines the string of text placed right of the check box graphic. If no text should be displayed an empty string (null) can be used. See 'encode' for a formatting example with embedded HTML commands.

·        tooltip

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

 

Attributes

M

Values

Usage

checked

 

TRUE
FALSE (d)

Taglib
checked ="TRUE"

Classlib
setChecked (true)

enabled*

 

TRUE (d)
FALSE

Taglib
disabled = "TRUE"

Classlib
setEnabled (false)

encode

 

TRUE (d)
FALSE

Taglib
encode = "FALSE"

Classlib
setEncode (false)

id

*

String (cs)

Taglib
id = "CheckCPU"

Classlib
setId ("CheckCPU")

jsObjectNeeded**

 

TRUE
FALSE (d)

Taglib
jsObjectNeeded = "TRUE"

Classlib
setJ
sObjectNeeded(true)

labeled

 

TRUE
FALSE (d)

Taglib
No tag available

Classlib
setLabeled (true)

text

 

String

Taglib
text = "CPU status"

Classlib
setText("CPU status")

tooltip

 

String

Taglib
tooltip = "Check CPU status"

Classlib
setTooltip("Check CPU status")

*     Method is inherited from the EventValidationComponent component. Therefore the attribute is different between the taglib and the classlib.

**    Method is inherited from the Component component.

 

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

 

Events

M

Values

Usage

onClick

 

String (cs)

Taglib
onClick = "process_checkbox"

Classlib
setOnClick("process_checkbox")

onClientClick

 

String (cs)

Taglib
onClientClick="alert('Click')"

Classlib
setOnClientClick("alert('Click')")

 

Example

using the taglib

    <hbj:checkbox
          id=
"CheckCPU"
          
text="CPU status"
          
tooltip="Check CPU status"
          
disabled="false"
          
checked="true"
    
/>

 

using the classlib

    Form form = (Form)this.getForm();
    Checkbox cb = 
new Checkbox("myCheckbox");
    cb.setText(
"CPU status");
    cb.setTooltip(
"Check CPU status");
    cb.setDisabled(
false);
    cb.setChecked(
true);
    form.addComponent(cb);

 

Result

This graphic is explained in the accompanying text

End of Content Area