Skip to content

jmix-create-detail-view: @NotNull Boolean checkbox cannot save false #35

Description

@fractal3000

What happened. A Customer entity had a required flag:

@NotNull
@Column(name = "SUBSCRIBED", nullable = false)
private Boolean subscribed = Boolean.FALSE;

jmix-create-entity prescribes @NotNull for a required field, and the component table
in jmix-create-detail-view maps Boolean to checkbox. Following both, the detail view
gets a checkbox bound to a mandatory attribute — and Jmix marks such a field required from
metadata. For a Vaadin Checkbox the empty value is false, so an unchecked required
checkbox is invalid: the save action silently does nothing and the view stays open. The
entity can never be created with the flag false.

How it surfaced. Only in a @UiTest that clicked save and then failed to find the
record. Nothing was logged: no exception, no validation message in the test output. Both
compileJava and a green clean test (before the UI test existed) passed. Diagnosing it
took a purpose-written probe over HasValidation.isInvalid() on every form field.

The fix is one attribute, and it is not mentioned in either skill:

<checkbox id="subscribedField" property="subscribed" required="false"/>

Why it matters. Two skills, each correct alone, compose into a defect. A required
boolean is an ordinary domain concept ("active", "public", "applies to orders"), the
default value is usually false, and the failure mode is silence rather than an error.
The same latent bug sat in a second detail view in this project and would have shipped,
because no test had ever unchecked that box.

Suggested fix. In jmix-create-detail-view, add a line to the Field Component Mapping
table or the Final XML Type Audit: a checkbox bound to a @NotNull Boolean must declare
required="false", since Vaadin treats unchecked as empty. Optionally note it in
jmix-create-entity next to the required-field defaults.


Found while building a real Jmix 2.8 application (document registry, Vaadin UI, PostgreSQL, deployed behind nginx).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions