Login Tags

GroovyMag Plugin Corner: Grails Searchable Plugin

One of the most powerful Grails plugins is also one of the easiest to use. The Searchable plugin brings the power of the Compass search engine into Grails in a very Groovy way. If you haven’t tried the Searchable plugin yet, it’s time to stop making excuses and stop wasting time building complex search forms for your projects. Let’s get started.

Strong Groovy

Usually Groovy is thought of as a loose, dynamically typed language that is otherwise similar to Java. Given this, it would make sense to write in Groovy when dynamism is needed an write in Java when you need strong typing, etc. to avoid side effects. But a great differentiator for groovy over any other dynamic language running on the JVM is that it also has all of Java's support for Strong typing, Generics, immutable objects and the like. This allows Groovy a tremendous range using dynamism where it makes sense and locking it down where it makes sense to do that.

Groovy Goodness: Setting a Closure's Delegate

Closures are reusable code blocks in Groovy. The code of the closure is executed against the delegate of the closure. By default the owner of the closure is the same as the delegate, but we can change this. We can define which object is the delegate for a closure, so we can change the object the closure is executed for.

Grails: A Quick-Start Guide Blog » Ajax-Enabled Checkboxes in Grails

In Grails: A Quick-Start Guide, we have a task list to help TekEvent organizers and volunteers keep track of what's left to be done for their event. It's pretty handy, but it could be a bit easier to use. Specifically, it would be great if we didn't have to click on a task to open the show view and then click again to edit it, just to mark a task as completed. What would be really nifty is if we could mark a task as completed by clicking on a simple checkbox. And it turns out that Grails provides an Ajax tag that's just what we need.

Groovy Goodness: Create Dynamic Methods

In Groovy we can write classes and write an implementation for methods we don't even know exist. We must implement the method methodMissing() which is invoked when other methods cannot be found.

Groovy Goodness: Finding Files with FileNameFinder

The groovy.util package contains the FileNameFinder and FileNameByRegExFinder classes. We can use the FileNameFinder classe to search recursively for files in a directory with ANT fileset pattern conventions. With the FileNameByRegExFinder we use regular expressions to define the file patterns.

Login

Filter by Tags