getLabelFor (Global objects and functions - JavaScript)

Gets the base object for the label associated with a UI component.

Defined in

Global objects and functions

Syntax

getLabelFor(component:javax.faces.component.UIComponent) : javax.faces.component.UIComponent
Parameters Description
java.faces.component.UIComponent A UI control.
Return value Description
java.faces.component.UIComponent The label control associated with the parameter.

Usage

A label is associated with a control by the for property which appears in the UI as Select target control.

If the label is not associated with a control, the following exception occurs: com.ibm.xsp.exception.EvaluationExceptionEx: Error while executing JavaScript computed expression.

Examples

This computed field displays the value of the label associated with an edit box.
try {
	return getLabelFor(getComponent("inputText1")).getValue()
} catch(e) {
	return "No label"
}