How can I get the OK button (windowCommitAndClose)

How can I get the OK button in Cuba?
I want to set it visible(false) inside an if condition.
I’ve tried in onInit

  Button commitAndCloseBtn = ((Button) getWindow().getComponent("windowCommitAndClose"));
        System.out.println("ssss" + commitAndCloseBtn);

but returns null.

Best Regards,
-n

Hello,

windowCommitAndClose is the id of the action, not a component’s id. Just define an id attribute for this button.

Or you can try this:

@Subscribe
public void onInit(InitEvent event) {
    Action action = getWindow().getAction("windowCommitAndClose");
    action.setVisible(false);
}

Thank you!
You made may day.