Touchkit Fallback Application

Hi there,
I’d like to have two different UIs for mobile browsers and desktop browsers. I read that this is possible specifying in web.xml a fallback application for non webkit browsers. I was not able to make the fallback application run when the browser is not webkit based. Please help me.

Here is my web.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="" xmlns:xsi="" xsi:schemaLocation="">
		<description>Vaadin production mode</description>
		<servlet-name>Vaadin Application Servlet</servlet-name>
		<!-- mobile app -->
			<description>Mobile app</description>
			<description>Application widgetset</description>
		<!-- fallback app + widgetset for non webkit browsers -->
			<description>Fallback app</description>
			<description>Application widgetset</description>
		<servlet-name>Vaadin Application Servlet</servlet-name>


The fallback application is only served for non-webkit users. So in you touch kit apps onBrowserDetailsReady method you should still check whether your device really is a touch device or not. If not, you can serve the desktop app or redirect your users to an address that always serves the desktop version. I’d probably do the latter. It paves way for possibility to use the desktop version with mobile version too if necessary (e.g. if you have touch optimized mobile version with only main feature and full featured desktop version, you might in some cases want to use the desktop version with your smartphone or tablet).


thank you for your answer Matti.

On my prototype I created two classes, as you can see on the web.xml file. Here is the code:


import com.vaadin.Application;
import com.vaadin.ui.*;

public class TestApplicationFallback extends Application {
	public void init() {
		Window window = new Window("Fallback app");
		window.addComponent(new Label("Fallback Webapp"));



import com.vaadin.addon.touchkit.ui.TouchKitApplication;
import com.vaadin.addon.touchkit.ui.TouchKitWindow;

public class TestApplicationMobile extends TouchKitApplication {
	private TouchKitWindow mainWindow;

	public void onBrowserDetailsReady() {
		mainWindow = new TouchKitWindow();
        mainWindow.setCaption("Mobile Webapp");


I thought that users will be redirected to the correct webapp automatically… Should I implement anything else?


Is it not possible to auto redirect to the correct web application based on browser or screen type? If the browser (or screen) is considered desktop-type then display desktop version, else display mobile version…

Anybody knows how to auto redirect to the correct web application based on browser or screen type? Please help


You can do this in two places:

In onBrowserDetailsReady() function you have full details about browser like if it supports touch events. At that point you have the most details to do your decisions. See e.g. our
demo app code here
. Instead of showing notification you can e.g. redirect to a different address like this: ExternalResource(""));

The decision whether the fallback application is chosen directly is done by the TouchKit servlet. If you know what version to show based solely on the request details you can also extend a special version of the servlet and override this method:

     * Method detects whether the main application is supported by the TouchKit
     * application. It controls whether an optional fallback application should
     * be served for the end user. By default the method just ensures that the
     * browser is webkit based.
     * @param request
     * @return true if the normal application should be served
    protected boolean isSupportedBrowser(HttpServletRequest request) {

BTW. If you want priority help for your team in cases like these, I’d suggest to use our Pro Support service. You’ll often get answers much quicker via that service.