Home > Java, Web > grails-jttaglib-0.1

grails-jttaglib-0.1

by paul on March 12, 2008

grails-jttaglib plugin is a small collection of convenience tags.

The sample code below assumes you have a domain class that looks like this:

 class Book {
   String title="my new book"
   String content

   static def constraints = {
      title(maxSize:20)
      content(maxSize:200)
   }
 }

When using these tags, you must have the following in the page – normally in the head block:

<g:javascript library="prototype"/>

<jttext:script />

textArea

Creates a TextArea HTML element, where the maximum number of characters is
limited by the constraints on the domain object, and tabs can be allowed if
desired.

Sample use:

<jttext:textArea object="${new Book()}" name="content" allowTabs="true"/>

<jttext:statusDiv for="content" />

The number of remaining characters available are displayed in the status div.
If allowTabs is set to true, tabs can be entered in the text area.

textField

Creates a text input type using maxlength from the objects constraints.
Sample use:

<jttext:textField object="${book}" name="title"/>

Generates:

<input type="text" name="title" maxlength="20" value="my new book" id="title" />

Download grails-jttaglib-0.1.zip

{ 1 comment… read it below or add one }

paul March 12, 2008 at 1:01 pm

I’ve noticed that there is a problem with this code in Opera – I’ve only tested it in Firefox 2 on Linux. I’ll try testing (and fixing) in IE and Opera soon. I assume its some JavaScript issue.

Leave a Comment

Previous post:

Next post: