You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by Bob Schellink <sa...@gmail.com> on 2008/10/17 18:50:39 UTC

Using Groovy with Click

Hi all,

Today I played a bit with Groovy which promises seamless integration 
with Java code. Thus one can use a dynamic language together with a 
Java framework such as Click.

 From the little testing I did it seems possible to author Click pages 
using Groovy. Below is my GroovyPage.groovy class:


class GroovyPage extends Page {

   onInit() {
       def form = new Form("form");
       form.add(new TextField("field");
       addControl(form);

       def label = new Label("label");

       // Note usage of multiline string below
       label.setLabel("""
           Hello
           <br>
           World!""");

       addControl(label);
   }
}

One thing which is not yet supported in Groovy is anonymous inner 
classes. But the rest should work fine. ;-)

bob