How can I create button's invoke method dynamically

i konw how do i create a button dynamically
but the button need a invoked method , and Each button has a different method
i need creat some Components through a loop,
when these Components be clicked , it will do something

So I thought about the button component, but i don’t know how to creat button’s invoke method dynamically,
the invoke method is like this :

 public void onButton_1Click(Component source) {

the button creat like this:
Button btn1=componentsFactory.createComponent(Button.class);

but the btn1 don’t have like this method: btn1 .setInvoke()

1 Like

Use the setAction() method instead.

For example:

Button button = componentsFactory.createComponent(Button.class);
button.setAction(new BaseAction("sayHello") {
    public void actionPerform(Component component) {


    <action id="sayBye" invoke="sayBye"/>
private Action sayBye;

public void init(Map<String, Object> params) {
    Button button = componentsFactory.createComponent(Button.class);

public void sayBye() {
1 Like