Grails Cookbook - A collection of tutorials and examples

Grails textArea Tag Example

The Grails textArea tag (<g:textArea>) can be used to render a <textarea> form control. This will show a simple example on how to use this tag.

Examples

Assuming this controller code action will pass a bean with property values

def create = {
    Person person = new Person()
    person.firstName = "John"
    person.lastName = "Doe"
    person.remarks = "Test Remarks"
    [person:person]
}

Specify Name

This Code:

<g:textArea name="remarks" value="${person.remarks}" />

Will render:

<textarea name="remarks" id="remarks" >Test Remarks</textarea>

Notice that name and id have the same value when no value for id is specified.

Specify Name And ID

This Code:

<g:textArea name="remarks" id="remarksTestId" value="${person.remarks}" />

Will render:

<textarea name="remarks" id="remarksTestId" >Test Remarks</textarea>

Rows And Columns


This Code:
<g:textArea name="remarks" rows="5" cols="40" value="${person.remarks}" />

Will render:

<textarea name="remarks" rows="5" cols="40" id="remarks" >Test Remarks</textarea>

CSS Class

This Code:

<g:textArea name="remarks" class="xyz" value="${person.remarks}" />

Will render:

<textarea name="remarks" class="xyz"  id="remarks" >Test Remarks</textarea>

Style

This Code:

<g:textArea name="remarks" style="width:400px; height: 200px;" value="${person.remarks}" />

Will render:

<textarea name="remarks" style="width:400px; height: 200px;"  id="remarks" >Test Remarks</textarea>


Other Grails Tag Examples


Tags: Grails Tag, textArea