Groovy Documentation

org.codehaus.groovy.grails.plugins.web.taglib
[Groovy] Class ValidationTagLib

java.lang.Object
  org.codehaus.groovy.grails.plugins.web.taglib.ValidationTagLib

@Artefact("TagLibrary")
class ValidationTagLib
extends java.lang.Object

Tags to handle validation and errors.

Authors:
Graeme Rocher


Property Summary
static java.lang.Object CONSTRAINT_TYPE_MAP

groovy.lang.Closure eachError

Loops through each error of the specified bean or model.

groovy.lang.Closure fieldError

Renders an error message for the given bean and field.

groovy.lang.Closure fieldValue

Obtains the value of a field either from the original errors.

groovy.lang.Closure hasErrors

Checks if the request has errors either for a field or global errors.

groovy.lang.Closure message

Resolves a message code for a given error or code from the resource bundle.

groovy.lang.Closure renderErrors

Loops through each error and renders it using one of the supported mechanisms (defaults to "list" if unsupported).

static java.lang.Object returnObjectForTags

groovy.lang.Closure validate

Validates a form using Apache commons validator javascript against constraints defined in a Grails domain class.

 
Method Summary
java.lang.Object eachErrorInternal(java.lang.Object attrs, java.lang.Object body, boolean outputResult = false)

java.lang.Object eachErrorInternalForList(java.lang.Object attrs, java.lang.Object errorsList, java.lang.Object body, boolean outputResult = false)

java.lang.Object extractErrors(java.lang.Object attrs)

java.lang.Object formatValue(java.lang.Object value, java.lang.String propertyPath = null)

Formats a given value for output to an HTML page by converting it to a string and encoding it.

java.lang.Object messageImpl(java.lang.Object attrs)

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Property Detail

CONSTRAINT_TYPE_MAP

static java.lang.Object CONSTRAINT_TYPE_MAP


eachError

groovy.lang.Closure eachError
Loops through each error of the specified bean or model. If no arguments are specified it will go through all model attributes and check for errors.
attr:
bean The bean to check for errors
attr:
field The field of the bean or model reference to check
attr:
model The model reference to check for errors


fieldError

groovy.lang.Closure fieldError
Renders an error message for the given bean and field.
eg. <g:fieldError bean="${book}" field="title" />
attr:
bean REQUIRED The bean to check for errors
attr:
field REQUIRED The field of the bean or model reference to check
attr:
message The object to resolve the message for. Objects must implement org.springframework.context.MessageSourceResolvable.
attr:
encodeAs The name of a codec to apply, i.e. HTML, JavaScript, URL etc
attr:
locale override locale to use instead of the one detected


fieldValue

groovy.lang.Closure fieldValue
Obtains the value of a field either from the original errors.
eg. <g:fieldValue bean="${book}" field="title" />
emptyTag:
@attr bean REQUIRED The bean to check for errors
attr:
field REQUIRED The field of the bean or model reference to check


hasErrors

groovy.lang.Closure hasErrors
Checks if the request has errors either for a field or global errors.
attr:
bean The bean to check for errors
attr:
field The field of the bean or model reference to check
attr:
model The model reference to check for errors


message

groovy.lang.Closure message
Resolves a message code for a given error or code from the resource bundle.
emptyTag:
@attr error The error to resolve the message for. Used for built-in Grails messages.
attr:
message The object to resolve the message for. Objects must implement org.springframework.context.MessageSourceResolvable.
attr:
code The code to resolve the message for. Used for custom application messages.
attr:
args A list of argument values to apply to the message, when code is used.
attr:
default The default message to output if the error or code cannot be found in messages.properties.
attr:
encodeAs The name of a codec to apply, i.e. HTML, JavaScript, URL etc
attr:
locale override locale to use instead of the one detected


renderErrors

groovy.lang.Closure renderErrors
Loops through each error and renders it using one of the supported mechanisms (defaults to "list" if unsupported).
emptyTag:
@attr bean The bean to check for errors
attr:
field The field of the bean or model reference to check
attr:
model The model reference to check for errors


returnObjectForTags

static java.lang.Object returnObjectForTags


validate

groovy.lang.Closure validate
Validates a form using Apache commons validator javascript against constraints defined in a Grails domain class.
TODO: This tag is a work in progress
attr:
form REQUIRED the HTML form name
attr:
againstClass REQUIRED the domain class name


 
Method Detail

eachErrorInternal

java.lang.Object eachErrorInternal(java.lang.Object attrs, java.lang.Object body, boolean outputResult = false)


eachErrorInternalForList

java.lang.Object eachErrorInternalForList(java.lang.Object attrs, java.lang.Object errorsList, java.lang.Object body, boolean outputResult = false)


extractErrors

java.lang.Object extractErrors(java.lang.Object attrs)


formatValue

java.lang.Object formatValue(java.lang.Object value, java.lang.String propertyPath = null)
Formats a given value for output to an HTML page by converting it to a string and encoding it. If the value is a number, it is formatted according to the current user's locale during the conversion to a string.


messageImpl

java.lang.Object messageImpl(java.lang.Object attrs)


 

Groovy Documentation