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?

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

Regards,
Natalia

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
            label.setValue(shiftStartDate.format(formatter));

            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?

2 Likes
@Subscribe
public void onInit(InitEvent event) {}

Hi.
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