View Mode; IsReadOnly()

I have an editor screen that is set up so i can get to it in view mode or edit mode.

I want to generate a table column only if the screen is in view mode. I was trying to use isReadOnly() as the conditional expression, however that does not seem to work.

Is there a way for me to check so i can do this?

Could you please share with us how exactly you trying to use isReadOnly() as the conditional expression?


if (isReadOnly()) {
        assignmentsTable.addGeneratedColumn("Date", entity -> {
            Label label = uiComponents.create(Label.class);

            //create formatter for shift date
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");

            //get shift shift date
            LocalDateTime shiftStartDate = entity.getShiftStartDate();

            //set column value with formatted shift time

            return label;

Could you please specify in which controller method your code is placed?

it is a screen that extends the StandardEditor.

So which method?

public void onInit(InitEvent event) {}

You need to subscribe toBeforeShowEvent instead. This event sent right before the screen is shown, i.e. it is not added to the application UI yet. Security restrictions are applied to UI components. In this event listener, you can load data, check permissions and modify UI components.

Thank you