Skip to content
Extensions for Groovy
Java Groovy
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
core
groovy-wicket-demo
groovy-wicket
.gitignore
README.md
pom.xml

README.md

GroovyWicket

GroovyWicket adds some additional functionality and syntactic sugar to the Wicket framework through the means of a Groovy Category along with a few simple implementations of certain Wicket components.

To use GroovyWicket you need wrap the code block where it is to be used as shown below.

use(GroovyWicket) {
    //do stuff
}

What Can It Do?

class MyPage extends WebPage {
    MyPage(PageParameters params) {
        super(params)
        use(GroovyWicket) {
            //create and add a MarkupContainer to the page
            panel(id) {MarkupContainer panel->
                //add a ListView to panel
                panel << ["Item 1","Item 2","Item 3"].listView("itemList") {ListItem<String> item->
                    //add a Label to the ListItem
                    item.label("itemLabel",item.modelObject)
                }
                //create and add a BookmarkablePageLink to any MarkupContainer
                panel.bookmarkLink("home",HomePage) {Link<HomePage> link->
                    link.label("homeLabel","Home")
                }
            }
        }
    }
}

Core

Currently not much is here except for a Groovy Category for working with the Java Calendar api.

SensibleCalendar

Some code examples

use(SensibleCalendar) {
    def cal = Calendar.instance
    cal.year(1972).month("JAN".month).day(2)
    println cal.time
    assert cal.year() == 1972
    assert cal.month() == JAN
    assert cal.day() == 2
}

use(SensibleCalendar) {
    def cal = new Date().toCalendar()
    assert cal instanceof Calendar
}

use(SensibleCalendar) {
    def cal = [
            year: 1981, month: 2, day: 22
    ].toCalendar()
    assert cal instanceof Calendar

    println cal.time
    assert cal.year() == 1981
    assert cal.month() == FEB
    assert cal.day() == 22
}

use(SensibleCalendar) {
    def result = "jan".month
    println "jan.month==$result"
    assert result == JAN

    result = "december".month
    println "december.month==$result"
    assert result == DEC
}

use(SensibleCalendar) {
    def result = "PST".timeZone()
    println "PST.timeZone==$result"
    assert result instanceof TimeZone
    assert result.ID == "PST"
}

use(SensibleCalendar) {
    withCal {
        println it
        assert it instanceof Calendar
    }
    def result = withCal([year:123,month:AUG,day:7]) {cal->
        println cal
        assert cal instanceof Calendar
        assert cal.year() == 123
        assert cal.month() == AUG
        assert cal.day() == 7
        return cal
    }
    assert result instanceof Calendar
}
Something went wrong with that request. Please try again.