Spring Mobile Grails plugin

3 votes
Dependency:
compile ":spring-mobile:0.5.1"

 Documentation  Source  Issues

Summary

Device resolver based on the Spring Mobile Library

Description

Introduction

This plugin is a wrapper around the Spring Mobile Project . The main feature is the detection of mobile devices for incoming HTTP requests.

Usage

The plugin adds dynamic methods to your controllers to determine what type of client is accessing the app:

isMobile() will be true if the client is a mobile phone.

isTablet() will be true if the client is a tablet.

isNormal() will be true if the client is not a mobile phone or tablet.

Additionally, you can run code conditionally, with access to the current org.springframework.mobile.device.Device instance, with this method:

withMobileDevice(Closure closure)

def list() {
   def view = "list"
   withMobileDevice { device ->
      view = "mobileList"
   }
   render(view: view, model: [list: listInstance])
}

By default the deviceResolver bean is an instance of org.springframework.mobile.device.LiteDeviceResolver but you can create your own and override the plugin's in grails-app/conf/spring/resources.groovy e.g.

deviceResolver(com.foo.bar.MyDeviceResolver)

Due to license changes, WURFL support was removed in version 0.5 of the plugin