A First Look at GroovySWT

May 31st, 2007

I’ve been working on my little app to Sync Outlook to Remember The Milk and having a great time learning GroovySWT along the way. GroovySWT offers a SwtBuilder and JFaceBuilder (simple DSL) for putting together SWT/JFace applications. Now I’m a huge fan of both SWT and JFace, so I was very keen to see what GroovySWT could let me do from straight groovy code.

It’s very early days for the GUI, but I’ve thrown together some scratchy ideas using the Tango Icon Library to get a basic interface underway.

SyncTheMilk in action on OSX

I still think the ideal way to build GUIs is with a tool. Even with the sensational DSLs that SwingBuilder and SwtBuilder give you, nothing beats dragging and dropping stuff around (personal fave is SWT Designer, which is unbelievably good - FD: I managed to get a free copy from the early days).

But if your GUI is very simple (like the one shown above), it really does seems a shame not to be able to throw something together really quickly using straight groovy, and GroovySWT gives you that in spades. How about a little Preferences dialog for your app which automatically persists user entries to a .properties file?

An SWT Preferences dialog

preferenceDialog() {

    preferencePage( title:"Proxy Settings", filename:"syncthemilk.properties" ) {
        booleanFieldEditor( propertyName:"proxyEnabled", title:"Enable Proxy" )
        stringFieldEditor( propertyName:"proxyHost", title:"Proxy Host" )
        integerFieldEditor( propertyName:"proxyPort", title:"Proxy Port" )
    } 		

    preferencePage( title:"RTM Settings", filename:"syncthemilk.properties" ) {
        stringFieldEditor( propertyName:"rtmToken", title:"RTM Token" )
    }
}

I’ve found a few little bugs in the current groovy-swt source which I’ll bundle up in a patch and submit once I have the full GUI for my app done. That should let me exercise a good part of the library.

The only major shortcoming I’ve found so far is there is virtually no documentation. There are, however, a ton of good examples that demonstrate many of the cool and interesting parts of the library (including tray integration, properties dialogs, wizards, and more). I’ll update the Groovy wiki with some new info once I’ve had a chance to get my own GUI done.

Huge props to Christiaan ten Klooster for all the fantastic work he has put into GroovySWT. Really a first class effort.

Glen Smith

Tags:

Oracle backs Groovy and Grails

May 29th, 2007

Around JavaOne 06, Oracle made a significant announcement which perhaps because of the hype around Ajax and EJB 3.0, was missed by many Java developers. Oracle announced its plan to support Groovy and Grails and the new JSR-223 specification to enable scripting languages. Groovy is an agile dynamic language for the Java Platform while Grails is an open-source web application framework that uses Groovy to bring Ruby On Rails ideas to the java world.

Although scripting languages have been a topic for discussion for some time now, none of the major Java players had invested much time, money and effort in pushing these languages. With this announcement, Oracle has got behind Groovy and Grails, which are both still in an early stage of development.

It is still anybody’s guess if scripting languages will catch on and maybe even replace the Java language, but with this Oracle announcement, languages like Groovy now have a better chance. Unless the marketing guys get to work very rarely does a technology become mainstream. We have a recent example of SOA, which many believe is an old idea recycled and hyped up.

The reason why Groovy and Grails are expected to do well is because although they introduce many new concepts meant to simplify development, they still stay close to the Java platform and enterprise Java development. While Groovy generates bytecodes that will run on the Java platform, Grails generates a J2EE application that can run on any J2EE server.

IndicThreads

Tags:

G2One Report (via Juixe TechKnow)

May 28th, 2007

The G2One, Groovy and Grails mini-pre-JavaOne conference, was put together by the folks behind No Fluff, Just Stuff conferences. The G2One mini-conference brought together Guillaume LaForge, the Groovy project lead, Graeme Rocher, Grails project lead, and Groovy in Action author Dierk Koenig amongst other Groovy developers and evangelist.

Guillaume started the event by proving a quick introduction of Groovy and going into the details of the upcoming release. Groovy provides semantic sugar and sweetness to the Java VM. Groovy is Java-like and compiles down to Java to byte code but with the added bonus of the GDK, the Groovy Development Kit. You can mix and match Java/Groovy classes seamlessly, no bridge/connector required. I think that Groovy is what Java 3 should and might be. For example, Groovy provides string substitution, array and map literals, and regex literals. There are Eclipse plugins for Groovy that come with code completion, navigation, and highlighting. Groovy 1.1-beta has support for annotations.

Graeme talked about the currently available Grails 0.5 release. Grails builds on top of Groovy as the language used in the models and controllers, Spring for the Inversion of Control container, Hibernate for the Object Relational Mapping, Quartz for task scheduler, and Sitemesh for templeting. Grails comes with an embedded Jetty servlet container and embedded HSQLDB database for quick turn around agile development. Graeme stated that most of the behavior in Grails is provided by plugins. So what is new in Grails 0.5? Command Objects in controllers. List and map support in GORM. Cascading validation. Script event hooks. Converter plugin to automatic convert models too XML, JSON, or RSS.

There was a series of rapid fire demoes by Guillaume, Graeme, Dierk, and other Groovy developers. One demo used the SwingBuilder groovy class to mashup GMaps and Flickr data. The demo used XMLSlurp to consume XML RSS feeds. Remixing and mashing up Google Maps and Flickr is like the ‘Hello, World’ first program of Web 2.0 mashups. When demoing the Swing-based mashup, Dierk Koenig said of the aesthetics of his demo, “This is what happens when you program in Swing, the first attempt is usually ugly.”

Juxie TechKnow

Tags:

“Groovy In Action” Rocks The House

May 25th, 2007

A lot has happened around Groovy since my last post.

First of all: Groovy has won the JAX Innovation Award 2007! This european prize honors the  most important innovation  for the  Java  platform in the last year, criteria being innovation, creativity, elegance, and practical relevance. Together with the prize comes a donation of EUR 10′000.- to the Groovy project.
I must say that the Groovy is not only proud but also very thankful for the recognition of our effort and all the great feedback from our friends like the JetBrains IntelliJ IDEA team.

The next big event was JavaOne in San Francisco, where numerous talks and events around Groovy and Grails took place. My co-author Guillaume Laforge and myself delivered a Groovy talk with huge success. The 600-seats room was not big enough to accommodate all interested parties and a long queue before the door was refused to enter.
Right after that, a booksigning event was scheduled for 30 minutes that had to be extended to one hour to satisfy all wishes for autographs.

Groovy in Action sold extremely well at the conference, finishing #5 in the overall bestseller list even though it was available only half of the time.

Since JavaOne, more reviews of the book have been published.

Burk Hufnagel reviews Groovy in Action on JavaLobby with the best possible rating in all categories. Some quotes from the review:
“If you’re a Java developer, or new Groovy developer, who is interested in becoming proficient in Groovy, this book is for you. And if you’re not interested, you should be.”
“Groovy in Action is an excellent book and I highly recommend it. It’s comprehensive and written to be read.”
“Do yourself a favor: buy the book, download Groovy, and have a blast.”

Pan Pantziarka reviews Groovy in Action on RegDeveloper with verdict “highly recommended”. Quote:
“Aside from the intrinsic interest in the subject matter, it has to be said that this is a book that is very readable, engaging, and does a great job of slotting Groovy into the broader world of software development.”

Here are some more voices from the blogoshpere:

O’Reilly radar:
The noticeable trend with the mid-minor languages is that Groovy came from nowhere and has now sold 1500 copies in the first quarter of 2007.

Dielehy
From all accounts the Groovy and Grails books at JavaOne were literally flying off of the shelves, they ran out several times (I personally have been waiting for Groovy In Action since I first heard about it).

Paul
To get started, I bought the Groovy in Action book. This is very well written and was easy to work through, and covered so much information I think I’ll be going back through it many times.

keep groovin’ everybody
Dierk König

Tags:

Going off the Rails on a Groovy Train - Part 1

May 24th, 2007

Many of my colleagues are (as is a lot of the web development world) really high on Ruby on Rails. And I can understand why. Really cool Web 2.0 sounding statements like “convention over configuration” or DRY (Don’t Repeat Yourself - which I just did by telling you what the acronym meant right after the acronym) are not just words, they’re baked in to the way Rails operates. Rails makes the every day of web application development uber-easy. And heck, Ruby has closures which almost any legitimate scripting language really needs.

But I’ve always had some problems with Rails. Some of these are admittedly probably based on my fear of change, but the four most substantial ones are:

  • Lack of libraries: to really make your life easier, a good scripting language or framework needs to have lots of libraries to do what you need. Ruby does have lots of libraries. But when I started trying to learn it, I had two needs, and I could not find libraries for either of the two. My Rails-uber-guru colleagues couldn’t find them either. That doesn’t mean they don’t exist, but in Perl - you go to CPAN. In PHP, you go to the centrail PEAR repo. In Java, if it’s not there already, Apache already wrote it. In Ruby, it might be on Rubyforge. Or there might be thirty of them hosted on various people’s blogs - no telling which ones are bulletproof. This will get better with time.
  • Lack of documentation: which is probably a legitimate complaint for anything FLOSS. And this goes hand-in-hand with the lack of libraries (or lack of a couple of de facto standard repo’s). With Java, you know the doc is good.
  • Inability to leverage existing work: For new applications, Rails is fantastic. But because Rails runs on Ruby, there’s not (yet) a way for me to leverage my existing work in existing VM’s without turning my existing work into web services (shame on me for not doing it right the first time - but did you?)
  • Key exposure: Part of the convention over configuration theme turns into key exposure. URL’s say things like http://server/blog/post/edit/832 - where 832 is the primary key field of the post I’m editing. Now, key exposure is not that big of a deal if 1) the key by itself has no meaning, which if you follow convention, it doesn’t, 2) there’s no SQL injection, which ActionRecord deals with nicely, and 3) you do permission checking for that object on every action - but that check is up to you.

That being said, Ruby on Rails is a really big and good step in the right direction. However, the first three items are killer for me - it doesn’t matter if I can “scaffold” a really complex schema in 8.3 seconds if I’m going to spend 8 weeks writing my own XSL translator or re-inventing the toaster oven.

In the next couple of posts, I’ll explain why I looked (back) into Groovy and why I’m (currently) geeking on Grails.

Sylvan von Stuppe

Tags:

Groovy Scripting Tips for Oracle ADF Business Components (Steve Muench)

May 22nd, 2007

Groovy Scripting Tips for ADF Business Components

ADF BC now provides integrated support for Groovy, a dynamic scripting language for the Java platform standardized in JSR 241. Groovy in ADF Business Components is dynamically compiled and evaluated at runtime. The JDeveloper/ADF 11.1.1.0.0 Technology Preview release is using the Groovy 1.0 release. The primary benefits of the ADF Business Components Groovy integration are:

  • Customization - because it is dynamically compiled, Groovy script can be stored inline in our XML and is eligible for customization
  • Simplification - Groovy supports object access via dot-separated notation

    so we can support syntax like:

    Salary * 0.10

    instead of

    ((Number)getAttribute(”Sal”).multiply(new Number(0.10))

    in Java in a calculated field expression,  or syntax like:

    PromotionDate > HireDate

    instead of

    ((Date)getAttribute(”PromotionDate”)).compareTo((Date)getAttribute(”HireDate”)) > 0

    in a validation rule.

You can use Groovy script expressions in the following different places in ADF Business Components:

  • Validation - you can use a Groovy script (that returns true or false) for declarative validation.
  • Validation Error Messages - you can use Groovy expressions to substitute the named tokens (e.g. “The value {val} is not legal.”}) in the error message
  • Bind Variables - you may define the value for a bind variable using a groovy script expression
    • Default Values
    • View Criteria
  • View Accessor Bind Variable Values - you may supply bind variable values in a view accessor using Groovy script
  • Attributes - you may base a transient attribute on a Groovy script
  • Attribute Default Values - you may define a default value expression on an attribute using groovy script

Keywords and Available names

The current object is passed in into the script as the ‘this’ object so to reference any attributes inside the current object, simply use the attribute name. For example, in an attribute-level or entity-level Groovy Script Expression validator, to refer to an attribute named “Ename”, the script may say simply reference Ename.

There is one top level reserved name adf to get to objects that the framework makes available to the groovy script. Currently these objects include:

  • adf.context - to reference the ADFContext object
  • adf.object - to reference the object on which the expression is being applied. This can also be referenced just using the keyword object without the adf prefix.
  • adf.error - in validation rules, to access the error handler that allows the validation expression to generate exceptions or warnings

All the other accessible member names come from the context in which the script is applied:

  • Bind Variable - the context is the variable object itself. You can reference the structureDef property to access other information as well as the viewObject property to access the view object in which the bind variable is defined.
  • Transient Attribute -  the context is the current entity or view row. You can reference all attributes by name in the entity or view row in which it appears, as well as any public method on that entity or view row. To access methods on the current object, you must use the object keyword to reference the current object like this object.yourMethodName(…) The object keyword is equivalent to the this keyword in java.  Without it, in transient expressions, the method will be assumed to exist on the dynamically-compiled Groovy script object itself.
  • Expression Validation Rule : the context is the validator object (JboValidatorContext) merged with the entity on which the validator is applied. You can reference keywords like:
    • newValue - in an attribute-level validator, to access the attribute value being set
    • oldValue - in an attribute-level validator, to access the current value of the attribute being set
    • source - to access the entity on which the validator is applied in order to invoke methods on it (accessing simply accessing attribute values in the entity does not require using the source keyword)

Usage Notes

This scripting logic works like JSF Expression Language (EL)  in the sense that you can use a dot-separated path to reference properties of an object and its nested objects. However one big difference is that if a Java object implements the java.util.Map interface, then only the map lookup is performed (instead of the bean style property lookup). For Maps that extend ADF’s JboAbstractMap class however, you get the same EL-style behavior: map lookup first followed by bean lookup. Additional usage notes include:

  • All Java methods, language constructs and groovy language constructs are available in the script.
  • You can use built-in aggregate functions on ADF RowSet objects by referencing the functions:
    sum(String attrName) — e.g. sum(”Salary”)
    count(String attrName)
    avg(String attrName) on a RowSet object where expr can be any groovy expression that returns a numeric value (or number domain).
  • Use the return keyword just like in Java to return a value, unless it’s a one liner expression in which case the return is assumed to be the result of the expression itself (like “Sal + Comm” or “Sal > 0“).
  • Use the ternary operator to implement functionality like SQL’s NVL() function. For example: Sal + (Comm != null ? Comm : 0)
  • Do not use { } to surround the entire script. Groovy treats { as a beginning of a Closure object - See groovy documentation for more on Closures.
  • Any object that implements oracle.jbo.Row, oracle.jbo.RowSet or oracle.jbo.ExprValueSupplier is automatically wrapped by the ADF runtime into a Groovy “Expando” object to extend the properties available for those objects beyond the bean properties (to enable easy reference to ADF row properties even if no Java class is generated, and as a way to avoid introspection for most used names).

Examples

This is a simple example of a view-object bind variable default expression that references the value of a key named FunctionalRole from the ADFBC Session’s user data hashtable:

viewObject.DBTransaction.session.userData.FunctionalRole

This is a simple example of an entity-level Groovy script expression validator. The strings ExcGreaterThanApplicationLimit, WarnGreaterThan5000, and ExcTooLow are message bundle keys to error/warning messages.

if (Sal >= 5000){
  /*
   * If Sal is greater than a property value set on the custom
   * properties map on the root AM raise a custom exception else
   * raise a custom warning
   */
  if (EmpSal >= source.DBTransaction.rootApplicationModule.propertiesMap.salHigh) {
    adf.error.raise("ExcGreaterThanApplicationLimit")
  }
  else {
    adf.error.warn("WarnGreaterThan5000")
  }
}
else if (Sal <= 1000) {
  adf.error.raise("ExcTooLow")
}
return true

Steve Muench

Tags:

Alternate Syntax For URL Mapping In Grails (Jeff Brown)

May 19th, 2007

One of the cool new features that was introduced with Grails 0.5 is Custom URL Mapping. The syntax for declaring the mapping looks something like this…

class MyUrlMappings {
  static mappings = {
    "/product/$id" {
       controller = "product"
       action = "show"
    }

     "/$blog/$year/$month/$id" {
          controller = "blog"
          action = "show"
          constraints {
               year(matches:/\d{4}/)
               month(matches:/\d{2}/)
          }
     }
  }
}

Since the release we have added support for an alternate syntax (which I happen to like) that looks like this…

class MyUrlMappings {
  static mappings = {
    "/product/$id" (controller:"product", action:"show")

     "/$blog/$year/$month/$id" (controller:"blog", action:"show"){
          constraints {
               year(matches:/\d{4}/)
               month(matches:/\d{2}/)
          }
     }
  }
}

Dynamic languages like Groovy make these sorts of things really easy to support. Behind the scenes of this url mapping there there is no grammar file and no tangly parser to manage. The configuration file is plain old groovy code. Blurring the line between code and configuration files by using a DSL like this is so much easier in Groovy that it might be in a language like C++ or Java. You have got to love it. :)

Jeff Brown

Tags:

Groovy and Grails: Three Worries (Graeme Rocher responds)

May 17th, 2007

I had the pleasure of meeting and having dinner (at a wondefully steriotypical American diner) with Stuart Halloway along with other NFJS guys like Ted Neward and Brian Goetz at JavaOne. Since then Stuart took the time to write a nice entry with a few pleasantries that he discovered about Groovy & Grails (Thanks Stuart!).

In a follow-up post entitled Groovy & Grails: Three Worries he raises a few concerns which I commented on, but would like to take the time to address here too.

1. Lack of Open Classes in Groovy

His first concern centers around the fact that Ruby has an open class system whilst Groovy does not. The reasons for this are simply Groovy compiles into byte code directly and there is a one-to-one mapping between a Groovy class and a class file. This is unlike JRuby where you need to to use proxying trickys in order to do things like call Ruby from Java.

So essentially Groovy can’t modify classes directly because as far as the JVM is concerned once a class is loaded it cannot be changed. Of course this is completely sensible as the Java platform has the concept of threading. Changing class definitions at runtime in a multi-threaded environment would be rather problematic from the JVMs perspective. Since Ruby has no concept of threading at this time of writing the language and runtime has no such concerns.

So given these constraints in Groovy we have a different way of doing things. Stuart presented the following example:


class Person {
  def firstName;
}
p = new Person();
class Person {
  def lastName;
}
p.lastName = 'Halloway'

In Groovy (with the upcoming 1.1 release) this would be implemented as:


class Person {
  def firstName;
}
p = new Person();
p.metaClass.lastName = 'Halloway'

p.lastName = "Rocher"

This uses Groovy’s ExpandoMetaClass mechanism. Since in Groovy we can’t change classes, we instead have a MetaClass for each java.lang.Class. The MetaClass defines the behaviour of the actual class. You change the MetaClass you change the class. So Groovy might not have “open” classes, but it has an equivalent mechanism for achieving the same thing.

2. OMG! Grails is not written in 100% Groovy!

Yes that is right Grails is around 80% Java and 20% Groovy. The reasons for this are several. Firstly, Java still makes a great language for writing low-level plumbing code. For dealing with all the complexities that the users of the higher level interface (Grails users) don’t have to deal with. Secondly, since Grails is written in Java we get the performance benefits of this. Grails is between 50 and 300% faster than Rails depending on the test. Rails might be implemented in 100% Ruby, but it has very well documented performance troubles because of this.

Do we eat our own dog food? Hell yeah, we have a plug-in system where plugins are all written in Groovy. All of our custom tag libraries are written in Groovy. Groovy Server Pages (GSP), our view technologies, is all Groovy. So we eat plenty of it trust me. Finally, the Groovy community has never been the one to cry out and tell everyone to ditch Java. No, our philosophy is to choose the right tool for the job, and Java is still a great tool in my toolbox just as Groovy is another. The fact that they work so seamlessly together is what makes the pairing so special.

3. The old static typing debate

So is static typing useful anyway? Well yes, it has been useful for a number of things for us such as enabling us to implement more intelligent scaffolding based on the types (java.util.Date, java.lang.String) etc. Also we could implement things like command objects which using static type information.

In addition at the moment the tool support just is not there yet to use either Ruby or Groovy for large complicated applications. Static typing analysis and the features that it brings to modern IDEs like refactoring and code navigation are just in a different league in Java. I hope this will change in time and since Groovy supports both static and dynamic typing I believe the tools vendors will have an easier time creating quality tools for it.

This is also where Grails fits quite nicely into the picture as it allows you to mix Groovy for the simple to medium complex stuff and Java to do the heavy lifting. IMO Groovy gets the balance here just right.

Graeme Rocher

Tags:

Grails + Wicket: The Wonders of the Grails Plug-in system (Graeme Rocher)

May 17th, 2007

Update: A shorter Wicket plug-in installation guide has been added here

A few people have been asking me recently to integrate the Wicket project as a view technology for Grails. What is Wicket? It is a component oriented framework kind of like JSF, but unlike JSF it uses convention-over-configuration and doesn’t require you to edit reams of XML. So in this sense its aims are more inline with Grails’ aims.

So the question was how do we integrate these two frameworks? Well I thought it couldn’t be that difficult and as it turns out, it isn’t. So what I did was create a plug-in with “grails create-plugin wicket”. The next thing I needed were some jars, so I got Wicket 1.2.6, Wicket Extensions 1.2.6 jar and the Wicket Spring integration jars for 1.2.6 and put them in the plug-ins lib directory.

Job done, now we need to set-up a convention that makes sense for both Grails and Wicket:

1) Since controllers are essentially roughly analogous to the Wicket Application object I decided that the convention would be to have a WebApplication.groovy file in the grails-app/controllers directory.
2) Wickets HTML components are like the views, so they can live in the grails-app/views directory

So to follow the HelloWorld example on the Wicket page we end up with something like this being the structure:

So just for clarify the WebApplication.groovy file looks like this:


import wicket.Page;
import wicket.spring.*;

public class WebApplication extends SpringWebApplication
{
public Class getHomePage()
{
return HelloWorld.class;
}
}

Whilst HelloWorld.groovy looks like this:


import wicket.markup.html.WebPage;
import wicket.markup.html.basic.Label;

public class HelloWorld extends WebPage
{
public HelloWorld()
{
   add(new Label("message", "Hello World!"))
}
}

Finally, the HelloWorld.html file looks like this:


<html>
<body>
<span wicket:id="message">Message goes here</span>
</body>
</html>

Ok so with that done, let’s take advantage of the conventions we have in place here. When I created the plug-in with “grails create-plugin” it also created me a WicketGrailsPlugin.groovy file in the root of the plugin project. Since the normal controller mechanism no longer makes sense we modify the plug-in to “evict” the controllers plug-in when installed:


class WicketGrailsPlugin {
def version = 0.1
def dependsOn = [:]
def evicts = ['controllers'] // evict the controllers plugin
 ...
}

With that done we now need to configure the Wicket “applicationBean” in Spring. To do this we’re going to use the GrailsApplication object and find a class that is an instance of a Wicket Application. This class just happens to be the one we defined earlier in grails-app/controllers:


import wicket.*
class WicketGrailsPlugin {
...
def doWithSpring = {
def applicationClass = application
                                   .allClasses
                                   .find { Application.class.isAssignableFrom(it) }

if(applicationClass) {
applicationBean(applicationClass) // defines the spring bean
}
}
}

We’re of course using the Spring BeanBuilder here to define the bean definition if the Spring context. Ok job done.

Now we need to modify web.xml.. but wait. In Grails even web.xml is created on the fly so other plugins can participate in its generation. So we can do this in the plug-in file again:


import wicket.*
class WicketGrailsPlugin {
...
def doWithWebDescriptor = { xml ->
   def servlets = xml.servlet[0]

   servlets + {
       servlet {
           ‘servlet-name’('wicket’)
           ’servlet-class’('wicket.protocol.http.WicketServlet’)
           ‘init-param‘ {
               ‘param-name’(’applicationFactoryClassName‘)
               ‘param-value’('wicket.spring.SpringWebApplicationFactory’)
           }
           ‘load-on-startup‘(1)
       }
   }

   def mappings = xml.’servlet-mapping’[0]
   mappings + {
     ‘servlet-mapping’ {
           ‘servlet-name’('wicket’)
           ‘url-pattern’('/app/*’)
      }
   }
}
}

Here we use Groovy’s XmlSlurper DSL to modify and the XML simply by using the + operator and some Groovy mark-up. We again use the Wicket Spring integration support to get it all working, so when Wicket loads it will actually look for the bean created by the Grails plug-in. And that’s it, to test the plug-in we can type “grails run-app” and navigate to http://localhost:8080/grails-wicket/app and we see:

Not hugely impressive I know, but what it does show is Wicket running as the view tech in Grails which means that Wicket components and applications can use GORM to simplify the ORM layer of Wicket applications and other features of Grails like Services and Jobs. This took me all of 20 minutes to write, in fact I’ve spent longer writing this article than the plug-in. Not that it is complete of course, things left to do are to add reloading support to the Groovy files that Wicket users. Advice from the Wicket community on how to do that would be appreciated. And of course I haven’t tested it against any more complex examples yet.

Now of course it wouldn’t be a plug-in if it couldn’t be installed into other apps. To do this we package it up with “grails package-plugin” which will create a zip. I’ve placed in plug-in at http://dist.codehaus.org/grails-plugins/ so in any Grails application you can now do:

grails install-plugin Wicket 0.1

or directly from the URL:

grails install-plugin http://dist.codehaus.org/grails-plugins/grails-Wicket-0.1.zip

And it will install this version of the plug-in.

Note: The plug-in doesn’t work with the Grails URL mapping mechanism in 0.5 so you need to delete any grails-app/conf/*UrlMappings.groovy files otherwise you’ll get an exception.

Plug-in sources can be found here: http://svn.grails-plugins.codehaus.org/browse/grails-plugins/grails-wicket/trunk

Graeme Rocher

Tags:

Groovy and Grails: Three Worries

May 16th, 2007

Yesterday I blogged ten pleasant surprises with Groovy and Grails. Let me reiterate that overall, I am impressed. But there are a still a few issues that make JRuby a more promising alternative at present.

  1. Groovy classes are not open. I understand the reasons for this decision, but I want the productivity boost possible in a language where this is legal:
    class Person {
      def firstName;
    }
    p = new Person();
    class Person {
      def lastName;
    }
    p.lastName = 'Halloway'

    My example here is trivial, but the concept isn’t. For more on both sides see here and here.

  2. Grails is not written in Groovy! (For the most part.) I went looking for the implementation of the chain method, and it was a whole Java class to itself. I am hoping that the Java bias is legacy, and that the Grails team is now more comfortable eating Groovy dog food.
  3. The “optional static typing” argument is a red herring, until somebody produces some compelling examples. Groovy advocates point out that they have the best of both worlds–dynamic typing with static typing available on request where needed. This sounds good, and it may be good, but show me some significant examples. Better yet, articulate some rules of thumb for when to use dynamic typing, and when to use static typing, within a single Groovy project. This is a serious request, not flamebait. Instead of debating “static typing–yes or no?”, let’s debate “static typing–when?” in a language with a clean syntax for both.

Stu Halloway

Tags: