Auto-Switching Touchkit Application

Hi Guys,

I have an application that has many “desktop” views - with lots of grids and what not, intended to be used by desktop users.

I’m wanting to replace some of those views with mobile friendly views which show the information in a much more mobile friendly way - and I can’t seem to find any documentation on how to approach this.

Is there a way to have the application or the navigator automatically switch between desktop and mobile views, so when logging in on a mobile device you get the mobile views, and when you log in using desktop you get the desktop views?

Currently I’m rolling a SpringViewProvider to load the UI’s as they are called.

Thanks!
~Ben

For this you need to modify the index.jsp since Touchkit is its own application sitting on its own URL. You can detect browser type by getting “user-agent” of the request and inspecting its value with suitable keywords. If you detect mobile browser, you can do sendRedirect(…) to URL where your mobile app is.

Not sure what you mean Tatu. There’s no index.jsp’s in this app at all.

The (desktop) application is running using vaadin-spring (annotated) to create the UI and map the URL’s.

Also, I don’t want a completely separate APP, there is shared business logic / database etc . I can roll a new UI and have the SpringUI provider do some trickery to delivery the “right” UI based on the user-agent, but I’m just not sure what is the best practice for this. Do I subclass the SpringUIProvider?

I would have thought most apps would have a mix of “mobile” and “desktop” views and that this would be easy.
The more I’m reading it seems that they do really need to have separate UI classes at the very least.

Ok, you are using Spring, then my first advice is not valid for you.

Vaadin Spring Add-On does support multiple UI’s, but having multiple serlvets needs some tweaking. Touchkit does not need to be totally separate app, but it is its own UI and has its own servlet. Hence you should check the starting instructions here.

https://vaadin.com/docs/-/part/framework/advanced/advanced-spring.html#advanced.spring.deployment

​There is own example app, that could help a bit (note, this is using an older version of Vaadin Spring-Add)

https://github.com/mstahv/vaadin-spring-touchkit