Images dont refresh after changing src - Using Push

I am using Push in my app. I have a broadcaster. And I can see that in both browser tabs the message is being received. But the image i am trying to change with setSrc() doesnt change. In my broadcaster i am using ui.access(). What am I still missing? Thanks.

@quintessential-ibex do you maybe still have my codebase checked out? I could once more use your help and a tip on this. But I can imagine you being busy. I tried adapting your change request with my own changes, but my main branch doesnt work and I cant find the reason why It works in your feature branch.

Do you have a small reproducible example?

The problem with the Image is maybe because it’s not a component but a Html element

@jovial-toad I tried it and it works

@PageTitle("Hello World")
@Route(value = "hello", layout = MainLayout.class)
@RouteAlias(value = "", layout = MainLayout.class)
public class HelloWorldView extends VerticalLayout {

    private final String[] images = {"https://www.bundesregierung.de/resource/image/1861386/16x9/1023/575/f3a046ae3b51331edec68bbbb9c8b0aa/gt/2021-02-24-corona-antigen-test.png",
            "https://www.anti-bias.eu/wp-content/uploads/2015/01/shutterstock_92612287-e1420280083718.jpg"};

    private int index = 0;

    public HelloWorldView(TaskExecutor taskExecutor) {
        setMargin(true);

        Label label = new Label();
        TextField name = new TextField("Your name");
        Button sayHello = new Button("Say hello");
        Image image = new Image();
        image.setSrc(images[index]);

        sayHello.addClickListener(e -> taskExecutor.execute(() -> {
            try {
                Thread.sleep(1000);

                name.getUI().ifPresent(ui -> ui.access(() -> {
                    label.setText("Hello, " + name.getValue());

                    index = index == 0 ? 1 : 0;
                    image.setSrc(images[index]);
                }));
            } catch (InterruptedException ex) {
                throw new RuntimeException(ex);
            }
        }));
        sayHello.addClickShortcut(Key.ENTER);

        add(name, sayHello, label, image);
    }

}

i dont have a small example. just my code so far. i could give you access to the github repo if you would like to take a look.

the thing is i have a feature branch from matti which works… but in my main branch with my changes it doesnt

and i dont get why

simasch is my GitHub account

The class “BattleMapService.java” is the one with the receive method. you can test the app by starting it, logging in with “fred”, “test”, then going to encounter in the menu and press “load encounter”

drag and drop works and moves the image

what i wanted to achive is that the image is being changed in every browser session

as a kind of “multiplayer”

the push message is being received as i can see in the log

I just had a look

what I don’t understand is where you place the image on the view

images[y] = createImage(“icons/token.png”, x, y);

Yeah but this image is not on the view

but its the array with the images that have been set to the view with public VerticalLayout createBattleMap(Encounter encounter)