How is the way to extends Components like Button


i am looking for a way to add some attributes to components (in my specific case it is a long field to a button component).

I need to build a list of buttons in program-code:

for (Integer i: intvalues) {
Button button = uiComponents.create(Button.NAME);

Now I need a way to do something like:

So: Is there a a way to create something like:

private class MyButton extends Button {
private Long number;
public void setNumber(Long p_number) {
number = p_number;
public Long getNumber() {
return number;

This would result in:
for (Integer i: intvalues) {
MyButton button = ???

Is there way to do something like this ?



Hello Martin!

Yes, you can extend the Button component. If you are not going to use this button in the descriptor you can do the following:

  1. Extend Button interface and WebButton class:
Code snippet
public interface ExtButton extends Button {

    String NAME = "extButton";

    void setLongValue(Long value);

    Long getLongValue();

public class WebExtButton extends WebButton implements ExtButton {

    protected Long longValue;

    public void setLongValue(Long value) {
        this.longValue = value;

    public Long getLongValue() {
        return longValue;
  1. In order to use your extended component you need to create ui-component.xml in the root package in web module:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<components xmlns="">
  1. In the file define the following property:

Then use ExtButton like this:

private UiComponents uiComponents;

public void onInit(InitEvent event) {
    ExtButton extButton = uiComponents.create(ExtButton.NAME);

See full example here: (80.3 KB)

P.S. For code formatting please use ```

1 Like

Hi Roman,

thanks very much for your reply. I think, this is the way for building
an own component library. But I just need a way, to put some kinds
of addon-information (things that make work easier on just a local state)
to a component.

A thing, that would help, would be an object-store like:

component.setAddonInfo(Object addoninfo);



With a attribute like this, some things would be easier to handle.