Using Groovy for Tacos-Demo & Tapestry

So, since groovy compiles down to bytecode, it can be used anywhere… That’s how i did a test tapestry page a month ago.

But this time i took some time off to play with groovy and the tacos demo app (Shing is hosting it for us right now) and the JetGroovy plugin of IntelliJ Idea 7.0M2. My findings are really nothing new and mostly deal with java vs. groovy … things!

So, the ajax tree demo uses a TreeData bean for its data… here it is in java:

 public class TreeData {
  private String name;
     private List<TreeData> children;
 
     public TreeData() {this(null);}
 
     public TreeData(String name) {
         this.name = name;
         children = new ArrayList<TreeData> ();
     }
 
     public String getName() { return name; }
 
     public void setName(String name) { this.name = name; }
 
     public List getChildren() { return children; }
 
     public void setChildren(List<TreeData> children) { this.children = children; }
 
     public void addChild(TreeData value) {
         String name = value.getName();
         for (int i = 0; i < children.size(); i++) {
             TreeData treeData = children.get(i);
             if (name.compareTo(treeData.getName()) < 0) {
                 children.add(i, value);
                 return;
             }
         }
         children.add(value);
     }
 
     public TreeData getOrCreateChild(String value) {
         for (TreeData treeData : children) {
             if (treeData.getName().equals(value))
                 return treeData;
         }
         TreeData data = new TreeData(value);
         addChild(data);
         return data;
     }
 }

and here it is in groovy:

 class TreeDataGroovy {
     String name
     List<TreeDataGroovy> children
 
     def addChild(TreeDataGroovy value) {
         if (children==null) children = [];
         int pos = children.findIndexOf { value.name < it.name }
         children.add(pos, value)
     }
 
     TreeDataGroovy getOrCreateChild(String value) {
         TreeDataGroovy data = children.find {it.name==value};
         if (data==null) {
             data = new TreeDataGroovy(name:value)
             addChild(data)
         }
         return data;
     }
 }

On the other hand, I ended up dealing with exceptions and errors quite more often that i do in java (perhaps due to my lack of knowledge for groovy) so it did force me in more unit tests, which some say is a good thing and others the opposite.

Tacos 4.1.0 released

Here’s the announcement:

Hi all,
It’s a pleasure for me to announce the release of Tacos 4.1.0
(http://tacos.sourceforge.net/tacos4.1/) – the first stable tacos
release supporting Tapestry 4.1.x and offering:
  • Dojo Widget – Generic component for (almost) all dojo widgets.

  • script.aculo.us – brand new components based on script.aculo.us

  • Comet component

  • New Annotations – allow you to inject ILinks and easily check if
    component parameters are bound.

  • New binding prefixes – including ‘template’ that makes string
    related ognl expressions easier, and ‘absoluteAsset’ which works like
    the asset binding but makes sure that the created url is absolute.

  • BeanForm – All-in-one, flexible bean editor BeanForm has become a
    major part of Tacos. This update offers complete compatibility with
    Tapestry 4.1.2.

  • Tapdoc – though not yet properly released from within tacos, it
    offers a maven plugin for component reference generation.

Furthermore:

  • The jars have already been deployed over at ibiblio.org – more
    installation instructions can be found at
    http://tacos.sourceforge.net/tacos4.1/tacos-core/quick-start/downloading.html

  • Beanform (http://beanform.sourceforge.net/) and Tapdoc
    (http://www.erinors.com/developer/project/tapdoc/) have merged
    with Tacos.

  • Huge thanks to our latest committer Igor Drobiazko whose excitement
    has shed new life to the project.

  • Extra special thanks to all the people that contributed code, esp.
    Daniel Gredler, Norbert Sandor, Patrick Moore, Ming Jiang and Craig Spry

Have fun with it!