Wicket Plugin
If you want to use the Wicket framework as an alternative view rendering technology ontop of GORM then this plug-in is for you
Features
The plug-in provides the following features:
- Hot reloading of the WicketApplication class
- Hot reloading of Wicket Pages and views
- Integration with GORM and the underlying Spring container
Installing the Plug-in
The plug-in is available from the Grails central repository and can be installed with:
grails install-plugin wicket
The installation process will create a class called WicketApplication at the location grails-app/conf/WicketApplication.groovy
Pages and Views
The plug-in provides a new directory under grails-app/pages where you should create your Wicket page classes which should end in the convention "Page" if you want hot reloading to happen. For example:
import org.apache.wicket.markup.html.WebPage import org.apache.wicket.markup.html.basic.Label import org.apache.wicket.PageParameters public class HelloPage extends WebPage { public HelloPage(final PageParameters parameters) { add(new Label("message", "If you see this message wicket is properly configured and running!")); } }
Now define the view in grails-app/views:
<html>
<body>
<span wicket:id="message">Message goes here</span>
</body>
</html>
Running the Application
Start-up your app with grails run-app then access http://localhost:8080/wicket-example/app
Comments (2)
Apr 18, 2008
jamesqiu says:
A problem: If I create a "MyPage.groovy" and "MyPage.html", How can I view MyPa...A problem:
If I create a "MyPage.groovy" and "MyPage.html", How can I view MyPage?
Any configuration in "WicketApplication.groovy" ?
What's the url ? ("http://localhost:8080/wicket-example/app/MyPage" or ..)
Thanks
Nov 29, 2008
JF ROMPRE says:
First, one should know that in the above example '/' is configured to go to the ...First, one should know that in the above example '/' is configured to go to the usual 'Welcome to Grails' page, and /app yields the HomePage wicket page (sadly, it took me a while to figure it out
. To give control of the root to Wicket, go to /plugins/wicket-<version number>/WicketGrailsPlugin.groovy and edit the line mapping the wicket servlet in the closure building the deployment descriptor:
...
def mappings = xml.'servlet-mapping'[0]
...
'servlet-name'('wicket')
'url-pattern'('/') //changed from 'url-pattern'('/app/')
..
To add other pages, one way is to "mount" them to a path expression, e.g. '/hello' to
the HelloPage above. Simply implement the init() method in grails-app/conf/WicketApplication.groovy, e.g.
....
protected void init() {
mountBookmarkablePage("/hello", HelloPage.class);
}
...
See wicket javadocs for org.apache.wicket.protocol.http.WebApplication