- Components
- Switch
Switch
Switches are toggle element that switch between an Off and On state on tap or click. A switch is backed by a checkbox input.
There is a client side Widget API as well as AJAX server callbacks available.
Example
Documentation
<t:switch value="#{bean.booleanValue}">
<f:ajax listener="#{controller.onSwitch}" render="noticiation"/>
</t:switch>
<button onclick="TW('myswitch').toggle()">Toggle with Widget API</button>
Switches are toggle element that switch between an Off and On state on tap or click. A switch is backed by a checkbox input.
Info
Tag name | switch |
---|---|
Component type | io.tornadofaces.component.Switch |
Renderer type | io.tornadofaces.component.SwitchRenderer |
Attributes
Name | Description | Required |
---|---|---|
value | The value | false |
styleClass | Styles to apply to the switch. | false |
style | CSS Styles applied to the switch. | false |
size | The size of the button: valid options are small, large. No value means default/medium. | false |
onChange | JavaScript callback when switch is flipped | false |
widgetVar | Widget variable name, accessible via TW('widgetVar') and TornadoFaces.widgets.widgetVar. | false |
rendered | Should this component be rendered? | false |
Client Side Callbacks
onChange
is called as the switch is flipped.
function onChange(switch) {
//
}
Ajax Behavior Events
change
will be called when a switch is flipped
<t:switch>
<f:ajax event="change" listener="#{controller.onChange}">
</t:switch>
public void onChange(SwitchEvent event) {
Switch _switch = event.getSwitch();
}
The listener will be called with an instance of io.tornadofaces.event.SwitchEvent
that contains a reference to the switch.
Client Side API
Widget: TornadoFaces.widget.Switch
Method | Params | Return type | Description |
---|---|---|---|
toggle() | void | Toggle the checked state. |