Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thymeleaf webflux: Only one data-driver variable is allowed to be specified as a model attribute, but at least two have been identified #298

Open
douma opened this issue Jul 11, 2022 · 2 comments

Comments

@douma
Copy link

douma commented Jul 11, 2022

I'm trying to create a dashboard application where multiple widgets get updates through SSE. My DashboardController looks like:

public class DashboardController
{
    private WidgetService widgetService;

    public DashboardController(WidgetService widgetService)
    {
        this.widgetService = widgetService;
    }

    @GetMapping("/")
    public String index(final Model model)
    {
        for(WidgetInterface<?> widget : widgetService.getAll()) {
            model.addAttribute("widget-data-driver-" + widget.getIdentifier(),
                    new ReactiveDataDriverContextVariable(widget.getInitialData(), 100));
        }
        model.addAttribute("widgets", widgetService.getAll());
        return "index";
    }
}

And my WidgetInterface:

public interface WidgetInterface<T>
{
    public String getIdentifier();
    public String getTitle();
    public String getStreamEndpoint();
    public Flux<T> getInitialData();
    public Map<String, String> getColumns();
    public String getThymeLeafFraction();
    public Date getLastItemDate();
    public Flux<T> getItemsUpdatedSince(Date date);
}

All is working fine for one widget (from the WidgetService). I'm trying to pass a ReactiveDataDriverContextVariable for each widget to Thymeleaf. But I get the following error:

org.thymeleaf.exceptions.TemplateProcessingException: Only one data-driver variable is allowed to be specified as a model attribute, but at least two have been identified: 'widget-data-driver-nufeed' and 'widget-data-driver-weatherapi'

I have two active widgets, one is an RSS feed an one implements weather api. How to can I set up the reactive variables for multiple widgets?

@douma
Copy link
Author

douma commented Aug 14, 2023

Is there a workaround for this issue? Please at least respond with why it was created this way for me to understand the possible limitations.

@douma
Copy link
Author

douma commented Aug 22, 2023

The first time the java community let's me down. I cannot ship the end product because of this error and why is nobody able to respond?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant