I have email confirmation on signup, as many apps do. I thought I could implement this with a Navigator.View without a UI. The view would intercept URLs of the form /#!confirm/UUID, perform validation magic, then redirect to a view that has visible UI components.
Unfortunately, this doesn’t work as I’d expect because I get an exception that the View isn’t a component. So clearly there is some way of handling this, and the way I’m currently trying isn’t it.
Can this be done from within Vaadin? I have a separate servlet that handles REST endpoints and other output types. I suppose I can redirect email confirmation there, but I’d really rather handle all user-facing endpoints in Vaadin if possible.
The way I do this is my app’s main UI looks for fragments matching the specified pattern (in your case anything starting with !confirm/ ) and then shows an appropriate view.
In that view, in the attach() method I use Page.getCurrent().getUriFragment() to get the current fragment and decide what to do next (extract the confirmation token then show a confirmation or error, etc).
I haven’t used “Navigator” yet as I didn’t know it existed (but after a quick look at the documentation I will probably switch to it as it seems I’ve duplicated it’s logic in my main UI).
You could use request handlers to do this if redirecting between browser pages is not a problem (not using a URI fragment but a normal path).
If you want to use the Navigator to avoid extra page loads, note that (if I remember correctly) neither Navigator nor View require views to be components but the default ViewDisplay implementation does. You can e.g. replace it with your custom ViewDisplay that handles the views that should not be shown and delegates the rest to its superclass.