Disable Button Action


I have a method and an if condition in order to disable a Refresh Button action.
I don’t want the Refresh Button to make invisible, just do nothing when is pressed (when the if condition is true).
How can I do that?


Hi @neutrino,

The RefreshAction has a setEnabled(boolean enabled) method to disable/enable action.

  • Enabled Refresh button
  • Disabled Refresh button

Add a refreshAction.setEnabled(condition) call in your method.


Hi Gleb,

I knew this option and that was the reason that I said “I don’t want the Refresh Button to make invisible, just do nothing when is pressed”.
The problem with this option is that before Disable take place the Refresh button start to perform its functiononce, which is not ok.

    public void onRefreshBtnClick(Button.ClickEvent event) {


private void refreshMethod(){


//press Refresh button - no action



press Refresh button - ok



@neutrino In case the Refresh action is to be performed, do you want to use the base implementation of the Refresh action or your own implementation?


I didn’t think about it. I use base implementation.
I can use a custom implementation as well, np.

Best Regards,

@neutrino you can overwrite RefreshAction and put your logic in CustomRefreshAction.actionPerform(Component component) function:

  1. CustomRefreshAction
import com.haulmont.cuba.core.entity.Entity;
import com.haulmont.cuba.gui.ComponentsHelper;
import com.haulmont.cuba.gui.Notifications;
import com.haulmont.cuba.gui.actions.list.RefreshAction;
import com.haulmont.cuba.gui.components.ActionType;
import com.haulmont.cuba.gui.components.Component;

public class CustomRefreshAction extends RefreshAction {

    public CustomRefreshAction(String id) {

    public void actionPerform(Component component) {
        if (condition1) {
            //press Refresh button - no action

        if (condition2) {
            //press Refresh button - ok
  1. In the web-spring.xml file, add <gui:actions> element with the base-packages attribute pointing to a package where to find your annotated actions:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    <!-- ... -->
    <gui:actions base-packages="com.company.sample.web.actions"/>

  1. Replace refresh action with customRefresh action in XML descriptor:
<groupTable id="customersTable">
        <action id="customRefresh" type="customRefresh"/>
        <!-- ... -->
        <button action="customersTable.customRefresh"/>

Please, see this topic, where you can find an another example of overwriting a standard action and see our documentation, which explains how to customize standard action.

In addition, in new CUBA 7.2 you can parameterize standard actions without overriding their behavior, see https://doc.cuba-platform.com/manual-7.2/standard_actions.html .
Would be great if you try the 7.2 BETA version and give us some feedback.


In order to do that I created a new package actions in com.company.sample.web and a new class CustomRefresh Action.
The problem is that here I don’'t have access to browse view elements so I cannot put the condition (ex. dateField.getValue()==null).