Dynamically Changing image in branding directory

Hi

I need to change the image in the branding (images on login screen) dynamically from the user end. I didn’t find any docs in specific on this dynamic update for branding with themes.

Is this possible with cuba?

Thanks

Hi,
It would help if you extended the Login Screen.

It is convenient to do in the Cuba Studio: choose the Login screen in the New → Screen wizard

Best regards,
Mariya

Hi

Thanks for the help.
Can u please give in detail how to assign image dynamically to a custom login screen.

Thanks

Hello, Tejasreesatti

I used cuba-petclinic project as an example.

I made changes to the PetclinicLoginScreen class:

@Inject
protected TextField<String> loginField;
	
@Override
protected void initLogoImage() {
    loginField.addValueChangeListener(e -> {
        if (loginField.getValue().equals("joy"))
            logoImage.setSource(RelativePathResource.class)
                    .setPath("VAADIN/brand-login-screen/petclinic_logo_body.svg");
        else
            logoImage.setSource(RelativePathResource.class)
                    .setPath("VAADIN/brand-login-screen/cuba-icon-login.svg");
    });
}

Please, see the project in the attachment:
cuba-petclinic-test.zip (13.6 MB)

Best regards,
Mariya

@sukhova

Hey … Thanks for the detailed description.

But instead of using set path and storing the image in VAADIN directory is there any other method we can use so that we can automatically get the image from the file explorer of the system?

That’s my requirement actually.

Thanks

Hello.

Please, see about the FileResource
Maybe it will be suitable for your purposes?

Best regards,
Mariya