iwebkit Plugin
Dependency :
compile ":iwebkit:0.5"
Summary
Installation
grails install-plugin iwebkit
Description
iWebKit
Author : Sébastien BlancThis plugin provides integration with iWebkit, a powerful User Interface Library for Safari development on iPhone. By using this plugin, the grails developer will not only have an iphone web app skeleton (CSS and javascript) but also an extended tag library helping in creating iphone web pages in an easy,clean and fast way.Version 0.4 release notes:
- iWebkit 5.0.4
- Removed Geolocation feature , iwebkit has now a dependency on the geolocation plugin
- Renamed namespace , the taglib is now under the namespace 'iwebkit' instead of 'iphone'
- Renamed layout, the plugin layout is now called 'iwebkit.gsp' instead of 'iphone.gsp'
screencast
Installation
grails install-plugin iwebkitUsage
After the plugin has been installed, just set the "iwebkit" layout :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="layout" content="iwebkit" />
<title>Note List</title>
</head> <body>Scaffolding
Scaffolding is a feature that I really like with grails so I decided to provide the same thing for the plugin. That means that you will be able to build a complete mobile website in less than 60 seconds :grails create-app bookstore grails install-plugin iwebkit grails install-iwebkit-templates
grails create-domain class book
class Book {
String name
String icon
}grails generate-all
new Book(name:'Grails in action',icon:'/bookstore/images/grails.png').save(); new Book(name:'Groovy in action',icon:'/bookstore/images/groovy.png').save();
TagLib - namespace 'iwebkit'
topbar
This will render the topbar of your webpage, a topbar can contain a title and navigation items.attributes :- title
leftnavigation
attributes :- navtype : "arrow" or "button"
rightnavigation
attributes :- navtype : "arrow" or "button"
navelement
leftnavigation and rightnavigation contains navelementatttributes :- action : maps to the controller action
- controller (optional) :specify a controller
- content : label of the navigation element
- image : link to image path
content
section
textbox
attributes : *header : header label of this textboxlist
This will render an "Iphoned" html list. The list tag supports the following attributes:- action : maps to the controller action
- controller (optional) :specify a controller
- descriptionField : String attribute that will be used as label
- imageField (optional) : path to associated image
- list: bean reference of the list
- customid (optional): useful for transient objects
Form support
Basically all the tags that you can use with grails core tag library are also available with the namespace "iphone" (i.e <iphone:submit/>). I got some issues with the select tag so this one is not available, but if you surround your regular g:select tag with the <iphone:section> tag it will works as wel.Orientation support
You can now use "untouchable links", that means that you can bind a link/action to a specific orientation of your iphone (portrait mode, landscape mode). Basically , it works the same way as the g:createLink, you just have to pass an extra parameter "value" wich contains the angle of your phone :<iwebkit:orientation> <iwebkit:angle value="90" action="addComment" id="${blog.id}"/> </iwebkit:orientation>
<iwebkit:orientation> <iwebkit:angle value="90" remote="true" update="tweetTimeline" action="updateTimeline" id="${user.id}" /> </iwebkit:orientation><div id="tweetTimeline"> … </div>
orientation
angle
- value: angle of your phone (90 : landscape left, -90:landscape right, 0: portrait)
- action : maps to the controller action
- controller (optional) :specify a controller
- id(optional) : id of your bean
- remote(optional): set this on true if you want to use ajax and update a html element of the current page
- customid : useful for not persisted objects
Geolocation support
Iwebkit depends on the geolocation pluginAlways dreamed to add location based services to your web application. Well that sounds a bit complicated to add this feature. Well with iwebkit plugin adding LBS to your site is as difficult as adding this tag in your page :<geolocation:locateMe/>