Dynamically add component

Hi,

I have a class witch implements
org.osgi.service.event.EventHandler
. This event should update (or redraw) a component in a verticallayout.

public void handleEvent(Event event) {
    verticalLayout.addComponent(new Label("test"));
}

If I use this code, the redraw is not triggered, only when I hit the refresh button of my browser, I see the new added component.

Adding
verticalLayout.requestRepaintAll();
to my code doesn’t solve it either.

Someone any idea how I can dynamically add (or update) ui components from an event?

(btw, when I add this component from a button.clicklistener, this works perfectly, only I don’t want to push on a button :slight_smile: )

Kind regards,
Stijn.


This thread
explains your problem.

Vaadin by default works by using client initiated request updates.
Which means that the client has to produce an event (like button click, …) for a request to be made to the server and the new UI content to be drawn.

It is possible to have server push (the server send update request) see for instance
this thread
which gives a good explanation in the first post.

Thanks for your answers!
The thread you advised cleared it out for me!

Issue solved.

How to create dynamic chart