getComponent (Global objects and functions - JavaScript)

Gets the base object for a UI component.

Defined in

Global objects and functions

Syntax

getComponent(id:string) : javax.faces.component.UIComponent
Parameters Description
id Name of the UI control.
Return value Description
java.faces.component.UIComponent The actual return type depends on the UI control. For example, an edit box is represented by an object of type com.ibm.xsp.component.xp.XspInputText. Typically the returned object has getValue and setValue methods for accessing the values received from and sent to the client.

Examples

For this example, you have three edit boxes named inputText1, inputText2, and inputText3 defined for numeric data. The third edit box has the following onfocus event. At runtime, clicking in the last box puts there the sum of the first two boxes.
getComponent("inputText3").setValue(
 	getComponent("inputText1").getValue() +
 	getComponent("inputText2").getValue())