Skip to content

Conditionally disable field #146

@mgodbole

Description

@mgodbole

I have an Entity

public class Institute extends AbstractEntity {

    @NotNull(message = "Domain required")
    @NotBlank(message = "Domain required")
    private String domain;

    @NotNull(message = "Display name required")
    @NotBlank(message = "Display name required")
    @Size.List({
            @Size(min = 5, message = "Min {min} characters"),
            @Size(max = 60, message = "Max {max} characters")
    })
    private String displayName;

    private boolean activeLicense = true;
}

Now my business logic dictates, the activeLicense should never be modified for certain institutes
I am aware, I can disable/hide fields on the editor, using the setVisibleProperties and setDisabledProperties from the FormFactory

I already have a selection listener on the grid to disable the delete button on some other business logic

        grid.asSingleSelect().addValueChangeListener(event -> {
            var institute = event.getValue();
            if (institute == null) {
                crud.getDeleteButton().setEnabled(false);
            } else {
                boolean shouldDisableDelete = //Some business logic
                crud.getDeleteButton().setEnabled(shouldDisableDelete);
            }
        });

I just can't figure out how to link the grid selection, to disabling/hiding the checkbox in the editor.
Any pointers to set me off on the right direction will be most appreciated.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions