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 7559501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:39:16+00:00 2026-05-30T12:39:16+00:00

Maybe this is an issue with persistance and the domain object. So I have

  • 0

Maybe this is an issue with persistance and the domain object. So I have a list of manual notes that can be added to a person. My person class looks similar to this (I’ve wrapped the object in transients to ignore persistence):

class Person {
...
List<String> notes = new ArrayList<String>()
...
}

When I update a person with a note (textfield on view will allow note to be added), I want to do something simple like adding the new note to the array list tied to the person:

class PersonController {
...
def update() {
    def contactInstance = Contact.get(params.id)
    if (!contactInstance) {
        flash.message = message(code: 'default.not.found.message', args: [message(code: 'contact.label', default: 'Contact'), params.id])
        redirect(action: "list")
        return
    }

    if (params.version) {
        def version = params.version.toLong()
        if (contactInstance.version > version) {
            contactInstance.errors.rejectValue("version", "default.optimistic.locking.failure",
                      [message(code: 'contact.label', default: 'Contact')] as Object[],
                      "Another user has updated this Contact while you were editing")
            render(view: "edit", model: [contactInstance: contactInstance])
            return
        }
    }

    contactInstance.properties = params

    /**
     * Check for inactive - Then flag with user and date tag
     */
    if(params.isActive == null) {
        DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm");
        Date date = new Date();
        contactInstance.properties.isActiveNote = "Made inactive by " + session.user + " on " + dateFormat.format(date) + "."
    }

    /**
     * Date stamp of the note itself
     */

    if(params.notes.equals("")) {}
    else {
        DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm");
        Date date = new Date();
        //contactInstance.properties.notes = contactInstance.properties.notes + "    " + params.notes + " - (" + dateFormat.format(date) + " " + session.user + ");"
        contactInstance.allThese.add(contactInstance.properties.notes)
        println(contactInstance.allThese)
    }


    if (!contactInstance.save(flush: true)) {
        render(view: "edit", model: [contactInstance: contactInstance])
        return
    }

    flash.message = message(code: 'default.updated.message', args: [message(code: 'contact.label', default: 'Contact'), contactInstance.id])
    redirect(action: "show", id: contactInstance.id)
}
...
}

The call to update from my gsp:

<g:actionSubmit class="save" action="update" value="${message(code:'default.button.update.label', default: 'Update')}" />

But it just seems to store the array with a single note. Is there a persistance issue with Grails domain objects and collections? It could very well be a simple issue on my end!

Thanks for all the help.

  • 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-05-30T12:39:18+00:00Added an answer on May 30, 2026 at 12:39 pm

    If your view includes multiple <input> fields or <textarea>s with the same name (“notes”, to match the field name in your Domain class), Grails will automatically bind the values to your notes array.

    You might also look into the new params.list() method that would allow you to iterate through request parameters and then add them individually to your array.

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

Sidebar

Related Questions

Maybe this is an encoding issue? I can't imagine that you have to replace
I've been struggling with this issue for a while now. Maybe you can help.
I have been looking for a better way to handle this issue maybe its
maybe you can help me out here. I have an issue with my codeigniter
Im having issues getting this to work, maybe its not even possible? I have
Maybe this is a dumb question, but I have the following behavior in Visual
Maybe this cannot be done, but please help or suggest how this can be
Maybe this is an easy question, maybe not. I have a select box where
I'm hoping maybe this is just an issue with the simulator but of course
Maybe it's related to this issue: https://github.com/thoughtbot/paperclip/issues/issue/346 But in Rails 3.0.3 (ruby 1.9.2) I

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.