Page tree
Skip to end of metadata
Go to start of metadata

Since Rabbtor Version 1.0.3, Rabbtor uses its own Grails implementation for GSP processing which is a customized version of Grails framework distributed through Rabbtor Maven Repository. This means, referencing any Grails jar from Grails framework's own repository may result in compatibility issues. For each Grails version, Rabbtor uses a similar version number such as,we have Grails 3.1.81, 3.1.82 ... versions which designates that the customizations are made on Grails 3.1.8

 

GSP is a template engine which uses Groovy for template scripting while it also supports Java code blocks, declarations and etc. just like JSP's. 

Rabbtor helps you integrate the Grails GSP libraries into a standard Spring MVC application with additional support for custom tag library registrations and automatic tag library discovery. 

Since the core implementation is provided by Grails, most common Grails GSP tags can be used with a few customizations and Rabbtor provides its own GSP tags for additional functionality. 

To configure and enable GSP, please check Configuring GSP section.

Why Another GSP When There Is Grails ?

First of all, Grails is a great framework which we use in most of our agile projects. And it is the main reason we loved GSP and we strive to use it for any other Spring based web project where we can not use Grails.

Everybody knows that choosing a template engine for Java web apps is a nightmare. A search on Google for "what is the best Java template engine?" shows many of us are in search for an answer and as in all such cases, there is no single truth. There are too many of them and each have their own goods and bads. GSP is our favorite for a very long time and it was really difficult until now to make it work outside a Grails app.

Actually we have been doing this with our custom tools for a while and then we decided to put all that work in a product which we now share with the public. 

Rabbtor does not aim to replace Grails' GSP implementation but adapt it to common Spring based MVC applications so that developers like us can now use GSP in their Spring app when using Grails is not an option. This is only possible referencing some Grails libraries so what we do is not rewriting GSP but integrating and customizing it. This adaptation is necessary because of the following facts:

  1. Grails GSP implementation currently can not easily be seperated from Grails itself. There is some work done by the Grails guys but till now it hasn't been maintained actively.
  2. Grails GSP tags use some internal Grails features which makes them incompatible with standard Spring MVC apps. That's why Rabbtor provides many custom GSP tags of its own as described later in this chapter.
  3. Integrating current Grails GSP system to a Spring MVC app require too much work which we make it easier using annotations and also configuration support. 
  4. Grails GSP does not provide data-bound FORM tags. This can be done with Grails plugins or some custom work but integrating them to our Spring apps would be much harder and prone to incompatibility issues. That's the reason we created data-bound FORM tags which work just like their Spring JSP counterparts of course with many additional improvements wihout sacrificing from the developer familiarity to the currently available Spring JSP tags. 

GSP Improvements

  • Data Bound Forms 

    • Rabbtor comes with its own FORM tags, written from scratch to mimic the way Spring JSP form tags work. Hence, all form tags work on command/model objects and support automatic binding and selection ( checkbox,radio, select ) of values 
      using the command/model properties. Usage and attributes are very different from the Grails GSP form tags. So please make sure you read our Data Bound Form Tags and Tag Reference sections and also the Spring MVC JSP tags documentation.

  • Spring Like Configuration

    • Rabbtor's GSP can be configured via Java Config classes or annotations or Spring Boot auto configuration. See Configuring GSP for more information.

  • Spring Like Usage

    • Rabbtor provides many GSP tags which resemble Spring JSP tags rather than Grails GSP tags to better suit the standard Spring MVC applications. Features like url generation, form data binding, html escaping use the standard Spring classes instead of Grails specific implementations. Usually, Grails has its own way of handling things which we removed in our GSP tags. Some Grails GSP tags however were left unchanged when there was no respactable difference between Grails and Spring implementations. See GSP Tag Reference for more information.

  • Designer Friendly Tags

    • With Rabbtor's GSP, you can use GSP tags in your views with attributes instead of custom tags. This enables designers to view GSP files in Web designer tools or browsers. For more information, see the examples given in Designer Friendly GSP Tags Using Attributes
  • Spring MVC Extensions

    • Rabbtor provides additional tags for MVC url generation, server side includes and more. See GSP Tag Reference for more information.

  • Tag Library Extension

    • Normally all custom tag libraries automagically inherit from the TagLibrary trait which provides common tag library methods and properties like "request", "response" and "out". Rabbtor provides  its own TagLibraryExt trait which actually inherits from the Grails' TagLibrary trait and helps accessing Spring MVC objects like the RequestContext. Tag library developers can directly inherit this trait to access these features.
  • Encoders

    • While Grails' encoders are supported, default html and javascript encoding in Rabbtor GSP tags use Spring's HtmlUtils and JavascriptUtils classes. See GSP Escape and GSP EscapeBody

 

Sitemesh

Grails GSP automatically support Sitemesh layout engine and Rabbtor has full support for the related GSP tags. Sitemesh is a decorator based layout engine which enables creation of very flexible nested layouts. 

Check out the Grails GSP documentation for more info.

For a few real life use cases, check out our example app which shows how we use layouts in our own projects.

Supported Tags

Below is a list of all GSP tags supported by Rabbtor. If no documentation link is provided here for a tag, please consult the corresponding Grails documentation ( tags section on the right of the page ). 

Grails Tags

  • g:each
  • g:if
  • g:else
  • g:elseif
  • g:unless
  • g:def
  • g:grep
  • g:findAll
  • g:collect
  • g:while
  • g:set
  • g:formatBoolean
  • g:formatDate
  • g:formatNumber
  • g:encodeAs
  • g:cookie
  • g:header
  • g:render
  • g:pageProperty
  • g:ifPageProperty
  • g:layoutBody
  • g:layoutTitle
  • g:layoutHead
  • g:applyLayout

Rabbtor Tags

See GSP Tags section for tag reference.