checkBox

checkBox is a component with two states: selected or deselected.

  • XML element: checkBox

  • Java class: JmixCheckbox

Basics

By default, Jmix Studio generates checkBox when creating an entity detail view with a Boolean attribute.

check box basics
<data>
    <instance id="userDc"
          class="com.company.onboarding.entity.User">
    <fetchPlan extends="_base"/>
    <loader/>
    </instance>
</data>
<layout>
    <checkbox label="Active"
              dataContainer="userDc"
              property="active" value="false"
              id="checkbox"/>
</layout>

In the checkBox element, the dataContainer attribute contains a link to the userDc data container, and the property attribute refers to the active entity attribute.

Attributes

ariaLabel

MDN

Set the accessibility label of this checkBox.

indeterminate

Set the indeterminate state of checkBox.

As according to the HTML5 standard, this has only effect on the visual appearance, not on the checked value.

value

Defines the value of checkBox. Can be true or false.

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 CodeGenerate 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();
    }
}

Elements

See Also

See the Vaadin Docs for more information.