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

  • SEARCH
  • Home
  • 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 7986433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:51:12+00:00 2026-06-04T11:51:12+00:00

Not sure what I am doing wrong here. I am hoping that it is

  • 0

Not sure what I am doing wrong here. I am hoping that it is something subtle. I can’t seem to pass errors to my gsp page. I have the following code in my controller:

def submit = {
    if (params) { // if there are parameters
        def sampleInstance = new Sample(params)// new sample
        if (sample.validate()) { // try to validate
            sample.save()
            flash.message = "Successfully Entered Sample"
            redirect ( action: 'sample' )
        }else{
            flash.message = "Error Entering Sample"
            sampleInstance.errors.each {
                println it
            }
            redirect ( action: 'sample', model:[sampleInstance:sampleInstance])
        }
    } 
}

I have verified that params is not null. Failed validation creates hasErrors() which also has been verified and the code sample.errors.each {println it} notifies me of the correct Field errors as I would expect. But something is wrong with my redirect syntax maybe? because the flash.message will work, but I cannot access the model:[sampleInstance:sampleInstance] map and no errors are rendered.

Here is the code in my gsp:

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

     </g:hasErrors>

My controller is called SubmitSampleController, the action is named submit, and the gsp page is called sample.gsp.

This may be an answer to my issue: I have another action called sample, maybe I need to perform all my logic inside the sample action, instead of inside the submit action? or is there a way to pass a model from one action to another action inside the same controller? I have a feeling my original model is getting lost.

def sample(){
    def now = new Date()// today's date
    def today = com.Sample.findAllBySampleReceivedDateGreaterThanEquals(now.clearTime())// finds all samples submitted today
   [checkDate:today, date: now] // passes a map of checkDate and todays date to the sample.gsp page
}
  • 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-04T11:51:13+00:00Added an answer on June 4, 2026 at 11:51 am

    In a redirect, the model is used as query parameters which is not that same as render, which does an actual forward and puts the objects in the request scope. What you need to do if there are errors is render a view and pass the model. Then you will get the desired output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure what exactly i'm doing wrong here...but i noticed that my File.Move()
Not sure what I'm doing wrong here. I have a struct that is used
I'm not sure what I'm doing wrong here... I have a custom HashTable that
I'm not sure what I'm doing wrong here - it seems that somethings is
I'm not sure what I'm doing wrong here, I have a file in lib/acts_as_votable.rb
Not sure what I'm doing wrong but I can't get my JQuery AJAX call
I am not sure what I could be doing wrong that causes info level
I'm not sure what I'm doing wrong, but two versions of code that should
I'm not sure what I'm doing wrong. I created a timer that updates a
ok not sure what i'm doing wrong here: $(#list).jqGrid({ url: --URL--, datatype: 'json', mtype:

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.