Best way of URL mapping for multiple UI classes?


Consider if:
I have multiple
UI
classes & I want to map them to different URLs so that each of them handles a different branch of URLs. Seems a typical situation to me.

What comes to mind:
I have to declare multiple
VaadinServlet
and declare each UI as
init-param
of that servlet, right?

Problem:
Assume that I want to change my
VaadinServlet
to a custom subclass in the future, I would have to change every servlet declaration.
DRY
applies, I think.

So I thought maybe I’m missing something. Is there another (better) way of doing this, than declaring multiple servlet elements?

VaadinSession.addUIProvider(UIProvider) allows you to add UI providers. You can also specify the UIProvider you want to use in your web.xml. You can extend UIProvider from abstract UIProvider class and based on the VaadinRequest you get as parameter there you can decide which UI to show. Just remember that if you overwrite createInstance method you really have to return new UI instance. Otherwise unexpected results may happen.

A little example on it would be really appreciated. How to show the admin dashboard when the login is successful ?