Change standard buttons visiblity as i click an item in a browse table

I asked a question in cuba chat: what method or listener is invoked when i click on GroupTable row. I want to make ‘remove’ button disabled when i select certain entries on a browse screen. is it achievable?

And got an answer: Extend RemoveAction, override the isApplicable method and provide custom logic.

but i’m not so confident to understand an answer… Can i have some more explanations?


You don’t need to add any listeners to disable the Remove button according to some conditions. As the Remove button is associated with the RemoveAction, you’re able to extend the RemoveAction and provide a custom implementation for the isApplicable method - a callback method which is invoked by the action to determine its enabled state. For example:

usersTable.addAction(new RemoveAction(usersTable) {
    protected boolean isApplicable() {
        // super implementation checks that 
        // target != null and target has selected items,
        boolean applicable = super.isApplicable();
        if (applicable) {
            // in this case we check that none of selected
            // users has login equals to 'admin'
            for (User user : usersTable.getSelected()) {
                if ("admin".equals(user.getLogin())) {
                    return false;

        return applicable;

Pay attention that if an Action instance is defined for a Button, the button will take the following properties from it: caption, description, icon, enable, visible.

1 Like

Thank you, it worked (and i guess i understand the concept)!