"Fossies" - the Fresh Open Source Software Archive

Member "grails-core-5.2.4/grails-docs/src/test/resources/docs/ref/Tags/hasErrors.html" (14 Sep 2022, 64891 Bytes) of package /linux/www/grails-core-5.2.4.tar.gz:

Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the grails-core-5.2.4.tar.gz project site itself.

(Quick Reference)



Checks whether a bean, request scope, or model reference has any errors and if so invokes the body of the tag. Typically used in conjunction with either eachError or renderErrors


Checks whether there are any errors for any bean throughout the request scope:

    <g:eachError><p><g:message error="${it}"/></p></g:eachError>

Checks whether there are any errors for the specified bean

<g:hasErrors bean="${book}">
    <g:eachError><p><g:message error="${it}"/></p></g:eachError>

Checks whether there are any errors for the field "title" of the specified "book" bean:

<g:hasErrors bean="${book}" field="title">
    <div class="errors">
       <g:renderErrors bean="${book}" field="title" as="list" />

As a method call in GSP:

<div class="prop ${hasErrors(bean:user,field:'login', 'errors')}">
    <label for="login"><input type="text" name="login" />

In this case we check for a field error on a particular field and set a CSS class on the surrounding div thus allowing us to highlight the error with a red border by appending the errors CSS class.

Checking for errors inside a nested object:

<div class="prop ${hasErrors(bean:parent, field:'child.name', 'errors')}">
    <label for="child.name" />
    <input type="text" name="child.name"
           value="${fieldValue(bean: parent, field: 'child.name'} />



  • bean (optional) - The bean to check for errors

  • model (optional) - The name of the model reference to check for errors

  • field (optional) - Check if a field of the bean or model reference has errors