Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9232335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:17:22+00:00 2026-06-18T06:17:22+00:00

i want get default error message in view if some error occuring while insert

  • 0

i want get default error message in view if some error occuring while insert an user. in controller i have 2 action:

def openPage() {
    [user: new User(params)]
}

def save() {
    User user = new User(params)
    if (!user.save(flush:true)) {
        redirect(view:'openPage', model:[user:user])
        return
    } else {
        flash.message = "User saved"
        redirect(action:'openPage')
    }
}

and this is my gsp:

<g:hasErrors bean="${user }">
    <g:eachError bean="${user }" var="error">
        <li>${error } </li>
    </g:eachError>
</g:hasErrors>



<g:if test="${flash.message }">
    ${flash.message }
</g:if>
    <g:form action="save"> 
        Name:<g:textField name="username"/>
        <g:submitButton name="ok" value="Save"/>
    </g:form>

but there’s something wrong and i can’t see any error if I sent no values. and this is my domain:

String username

static constraints = {
    username(nullable:false, blank:false, unique:true)
}

what’s is wrong with my code? pls help. and must i use this method for catching errors or it’s better do it with if…else and try…catch?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:17:23+00:00Added an answer on June 18, 2026 at 6:17 am

    Call render instead of redirect() method if save fails:

    if (!user.save(flush:true)) {
        render(view:'openPage', model:[user:user])
        ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been getting this error message when I step into some methods Do
I'm using sfGuard plugin for Doctrine. I want to override the default error message
I want to get Default Windows Forms Unhandled-Exception Dialog whenever my C# application encounters
Basically I want get data I already have accessed from javascript and passing it
I want to change the default error messages being thrown by Spring. I basically
I want my User Control to be able to have Literal Content inside of
I have this following code in my controller. I want to print the data
I have this in my route file: devise_scope :user do get /admin, :to =>
I want to get the current page URL from my default_popup page like this:
I want get the time used for a case so I can create an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.