Spring Mobile Grails plugin
Dependency :
compile ":spring-mobile:0.4"Custom repositories :
mavenRepo "http://snapshots.repository.codehaus.org/" mavenRepo "http://maven.springframework.org/milestone/"
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 will inject the following dynamic method inside your controllers :withMobileDevice(Device device,Closure closure)The plugin is shipped with 2 different device resolvers, the default one is the lite resolver :def list = {
def view = "list"
withMobileDevice {
view = "mobileList"
}
render(view: view, model: [list: listInstance])
}def list = {
withMobileDevice {def device ->
println device //The toString() shows a lot of information about the device
def view = "list"
if(device.id.contains("iphone"){
view = "iphoneList"
}
view ="mobileList"
}
render(view: view, model: [list: listInstance])
}[WurflDevice mobile=true, id=apple_iphone_ver4_1_sub8b117, userAgent=Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7, capabilities ={screensaver_greyscale=false, fl_wallpaper=false, mms_xmf=false, columns=20, viewport_supported=true }, markup=XHTML_ADVANCED]
springMobile {
deviceResolver="wurfl"
}