checkBox
checkBox
is a component with two states: selected or deselected.
-
XML element:
checkBox
-
Java class:
JmixCheckbox
Data Binding
You can bind a component to an entity or its attributes hold in a data container.
To bind checkBox
to an entity attribute:
-
Specify the name of the data container as the dataContainer attribute value.
-
Specify the name of the entity attribute as the property attribute value.
The entity attribute must be of Boolean
type.
<data>
<instance id="userDc"
class="com.company.onboarding.entity.User">
<fetchPlan extends="_base"/>
<loader/>
</instance>
</data>
<layout>
<checkbox label="Active"
dataContainer="userDc"
property="active"
id="checkbox"/>
</layout>
Attributes
id - alignSelf - ariaLabel - autofocus - classNames - colspan - dataContainer - enabled - height - indeterminate - label - maxHeight - maxWidth - minHeight - minWidth - property - readOnly - requiredIndicatorVisible - tabIndex - value - visible - width
Handlers
To generate a handler stub in Jmix Studio, use the Handlers tab of the Jmix UI inspector panel or the Generate Handler action available in the top panel of the view class and through the Code → Generate menu (Alt+Insert / Cmd+N). |
ClickEvent
com.vaadin.flow.component.ClickEvent
is sent when the user clicks checkBox
.
@Autowired
private Notifications notifications;
@Subscribe("checkbox")
public void onCheckboxClick(final ClickEvent<Checkbox> event) {
if (Boolean.TRUE.equals(event.getSource().getValue())) {
notifications.create("set")
.show();
} else {
notifications.create("not set")
.show();
}
}
See Also
See the Vaadin Docs for more information.