Override default cuba methods/properties

image

I have a problem with fast clicking, it opens multiple instances of the same action.
I want to set this field as true for every button in my application.
How can i set global defaults or override these methods inside the jar file

Hi,

You can replace the standard Button implementation with your own. Use the following steps:

  1. Create CustomWebButton class
import com.haulmont.cuba.web.gui.components.WebButton;

public class CustomWebButton extends WebButton {
    public CustomWebButton() {
        component.setUseResponsePending(true);
    }
}
  1. Create components.xml file in web module (in your root package, com.company.demo in my app):
<components xmlns="http://schemas.haulmont.com/cuba/components.xsd">
    <component>
        <name>button</name>
        <class>com.company.demo.web.components.CustomWebButton</class>
    </component>
</components>
  1. Register this file in web-app.properties:
cuba.web.componentsConfig = +com/company/demo/components.xml

Now you can run your application and try to set a break point in your button class.

1 Like

Hello, thank you for the detailed answer
When following your guide, i get an error that tag is missing for my component in components.xml

I ignored the error and tried the guide anyway but it is not working, most probably due to this error.
I would really appreciate any documantation you have on cuba.web.componentsConfig

Thank you

It seems that you use one of the previous platform versions. Define components.xml as follows:

<components xmlns="http://schemas.haulmont.com/cuba/components.xsd">
    <component>
        <name>button</name>
        <class>com.company.demo.web.components.CustomWebButton</class>
        <tag>button</tag>
        <componentLoader>com.haulmont.cuba.gui.xml.layout.loaders.ButtonLoader</componentLoader>
    </component>
</components>

2 Likes

This is exactly what i was looking for.
Thank you.