Javatpoint Logo
Javatpoint Logo

PrimeFaces InputSwitch

It is used to take a boolean value as input from the user. It is a button which toggles ON or OFF. We can create it by using <p:inputSwitch> component. It also provides various attributes that are tabled below.

InputSwitch Attributes

Attribute Default value Type Description
onLabel on String It is used to set label for on state.
offLabel off String It is used to set label for off state.
label null String It is used to set label for the component.
disabled null String It is used to disables or enables the switch.
onchange false Boolean It is used to call client script on value change event.
style null String It is used to set inline CSS of the main container.
tabindex null String It specifies the tab order of an element.
showLabels null String It is used to set the visibility of the labels.
onfocus null String It executes when component receives focus.
onblur null String It executes when component loses focus.

Example

Here, in the following example, we are implementing <p:inputSwitch> component. This example contains the following files.

JSF File

// switch.xhtml

ManagedBean

// SwitchDemo.java

Output:

PrimeFaces InputSwitch 1
PrimeFaces InputSwitch 2





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA