Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

spring-touchkit 0.0.

2 Manual
Christoph Guse
Copyright 2012 www.flexguse.de

Table of Contents
Introduction ....................................................................................................................... Installation ........................................................................................................................ Using spring-touchkit .......................................................................................................... Class inheritance ........................................................................................................ AppWidgetSet.gwt.xml ................................................................................................ web.xml .................................................................................................................... Demo application ............................................................................................................... 1 1 1 1 2 2 3

Introduction
The spring-touhkit addon provides integration of the Spring Framework with Vaadin TouchKit applications. It is based on the Spring Stuff addon provided by Archie Cobbs and the Vaadin TouchKit addon provided by Vaadin Ltd.

Installation
To use spring-touchkit you need the Jar files for Spring 3.11.RELEASE (or higher), Spring-Stuff 1.0.432 (or higher) and vaadin-touchkit-apgl 2.1.1 or higher and all of it's dependencies. Therefore it is hardly recommended to use Maven to handle the dependencies. You can find the current spring-touchkit Maven dependency configuration in the Vaadin addon directory.

Using spring-touchkit
Class inheritance
Normally a TouchKit aplication extends the TouchKitApplication. In case of a spring-touchkit application your extend the SpringTouchkitApplication. public class DemoMobileApplication extends SpringTouchkitApplication { ... } In a standard TouchkitApplication the method onBrowserDetailsReady() is called after all initialisation was done. In a spring-touchkit application the method is called too, but additionally the method initSpringApplication(ConfigurableApplicationContext context) is called after all Spring initialisation was done. public void onBrowserDetailsReady() {

spring-touchkit 0.0.2 Manual

// do some UI things which need no Spring configured things } protected void initSpringApplication(ConfigurableWebApplicationContext context) { /* * Initialise the application. Don't forget to run the init method in * the super class, otherwise you get an error the Vaadin Application * Window can't be found. */ super.initSpringApplication(context); } Do NOT forget to call super.initSpringApplication(context).

AppWidgetSet.gwt.xml
As far the author of spring-touchkit knows the Vaadin TouchKit widgetset needs to be compiled. As spring-touchkit uses the standard Vaadin TouchKit addon the widgetset needs to be compiled in each project. To do so create a widgetset definition AppWidgetSet.gwt.xml somewhere in the classpath of you application. In the spring-touchkit-demo application this was done in the package de.flexguse.vaadin.addon.spring.touchkit.demo.gwt. <module> <!-This file is automatically updated based on new dependencies by the goal "vaadin:update-widgetset". --> <!-- Inherit DefaultWidgetSet --> <inherits name="com.vaadin.terminal.gwt.DefaultWidgetSet" /> <inherits name="com.vaadin.addon.touchkit.gwt.TouchKitWidgetSet" /> <set-property name="user.agent" value="gecko1_8,ie8,safari,opera" /> </module> The property user.agent was set to all available browser so the resulting spring-touchkit application not only runs on iOS devices with Safari and Android devices with the default WebKit browser, but also on Android devices with Opera Mini and other browsers installed. Enable the vaadin-maven-plugin in your application POM to compile the TouchKit widgetset automatically during build.

web.xml
In the web.xml the widgetset must be applied. This is done adding this init-param in the Vaadin application servlet. The following snippet shows the setting for the spring-touchkit-demo application. <init-param> <description>Application widgetset</description>

spring-touchkit 0.0.2 Manual

<param-name>widgetset</param-name> <param-value>de.flexguse.vaadin.addon.spring.touchkit.demo.gwt.AppWidgetSet</para </init-param> The next init-param is optional. Spring-Stuff normally is looking for an Spring context configuration file in the WEB-INF folder which is named like the spring-touchkit application you are writing. If you don't like this default behavior you can configure the location of the application context file using an initparam in the Vaadin application servlet. <init-param> <param-name>vaadinContextConfigLocation</param-name> <param-value>/WEB-INF/spring/mobileApplicationContext.xml</param-value> </init-param>

Demo application
The spring-touchkit-demo application is included in the sources. Check out all sources from https:// bitbucket.org/flexguse/spring-touchkit and do the following steps: 1. Compile and install the entire project: $ mvn install (absolutely necessary to run, widgetsets are compiled) 2. Start the built-in Jetty web server: $ cd demo $ mvn jetty:run 3. Open your favorite web browser and point it to: http://localhost:8080/demo/

You might also like