Dashboard > blojsom > ... > Developers Guide > Configuring the Groovy dispatcher
  blojsom Log In   View a printable version of the current page.  
  Configuring the Groovy dispatcher
Added by David Czarnecki, last edited by David Czarnecki on Dec 21, 2004  (view change)
Labels: 
(None)

Groovy "is a new agile dynamic language for the JVM combining lots of great features from languages like Python, Ruby and Smalltalk and making them available to the Java developers using a Java-like syntax."

Installing the Groovy dispatcher

You must download the blojsom add-on bundle. It is available as a separate download with each release of blojsom.

  • Unpack the add-on bundle ZIP file.
  • Copy the asm-1.4.jar and groovy-1.0-beta-4.jar files to your blojsom installation's /WEB-INF/lib directory.
  • Add the following line to your /WEB-INF/dispatcher.properties file.
    groovy=org.blojsom.dispatcher.GroovyDispatcher
    
  • In the above configuration, Groovy templates will be associated with the .groovy file extension.
  • You may then add templates to an individual user's /WEB-INF/(blog-id)/templates directory that use Groovy.
  • You must restart your server if you are adding the Groovy dispatcher while blojsom is running.

Configuring the Groovy dispatcher

There are no configuration options for the Groovy dispatcher.

Configuring a flavor template to use the Groovydispatcher

You can configure individual flavors to use the Groovy dispatcher by changing the properties in your /WEB-INF/(blog-id)/flavor.properties file. For example:

html=html.vm, text/html;charset=UTF-8

This line in the flavor.properties file configures the html flavor to use the html.vm template, where in the standard blojsom installation, templates with a .vm extension are associated with the Velocity dispatcher.

To configure the html flavor to use the Groovy dispatcher, change the line above to the following:

html=html.groovy, text/html;charset=UTF-8

You will then need to create the appropriate /WEB-INF/(blog-id)/templates/html.groovy file using the Groovy template syntax.

Writing templates using Groovy

The Groovy dispatcher uses the Simple Template Engine as the basis for writing templates.

This simple template engine uses JSP <% %> script and <%= %> expression syntax. It also lets you use normal groovy expressions in the template text much like the new JSP EL functionality. The variable 'out' is bound to the writer that the template is being written to.

Please read the Groovy language guide for the details on the Groovy language syntax.

Site running on a free Atlassian Confluence Open Source Project License granted to blojsom. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.4 Build:#809 Jun 12, 2007) - Bug/feature request - Contact Administrators