medusa-ui/medusa

different controllers should be able to point to the same page

Closed this issue · 1 comments

ref: bug example

If multiple UIEventHandlers point to the same page, only the last one is 'remembered' by the EventHandlerRegistry.
I think the route (path) should be unique, and not the page (file)

Ref example in the branch:
With

@UIEventPage(path="/test/bug/hello", file = "pages/integration-tests/bug/hello")
public class HelloUIEventHandler implements UIEventWithAttributes {

    @Override
    public PageAttributes setupAttributes(ServerRequest request, SecurityContext securityContext) {
        return new PageAttributes()
                .with("controller","HelloUIEventHandler");
    }
}

and

@UIEventPage(path="/test/bug/welcome", file = "pages/integration-tests/bug/hello")
public class WelcomeUIEventHandler  implements UIEventWithAttributes {

    @Override
    public PageAttributes setupAttributes(ServerRequest request, SecurityContext securityContext) {
        return new PageAttributes()
                .with("controller","WelcomeUIEventHandler");
    }
}

and

<body>
<h1>🦑 Medusa in trouble</h1>
<p>Controller name: [$controller]</p>
</body>

(note both controllers point to file = 'pages/integration-tests/bug/hello')
then both routes (/test/bug/welcome and /test/bug/hello) show Controller name: WelcomeUIEventHandler

Fixed with #46