0

Possible Duplicate:
Best way to pass objects between controller actions in grails

I have a def show in a controller which should send information as object to action show in other controller i tried

def show() {
        Person personDomainInstance = getPersonById(params.personId)

            redirect(controller: "NewPersonController", action: "show", personDomainInstance:personDomainInstance)
        }
    }

when i try this it displays The requested resource (/......./show) is not available. Am I following the right approach for redirect . Can i pass object in this way??Also one more question is how can I bind person Domain object to domain instance object of NewPersonDomain object.

Community
  • 1
  • 1
Suryateja Kosaraju
  • 493
  • 1
  • 7
  • 14
  • Possible duplicate: [Best way to pass objects between controller actions in grails](http://stackoverflow.com/q/9751211/462015) – Arturo Herrero Apr 23 '12 at 07:55

2 Answers2

1

You can't pass an instance variable in one controller to another, you'd have to pass the id, and have the second controller load it again. It will probably be cached from the first load, so it would come from the cache, and not actually have to be reloaded.

RadBrad
  • 7,234
  • 2
  • 24
  • 17
0

I had a similar question a bit ago, and I ended up adding the object to the servletContext object. If this needs to change per user, it's suggested to add it to the session.

Servlet context info --> http://www.grails.org/doc/latest/ref/Controllers/servletContext.html

Full thread where I previously asked this --> http://grails.1312388.n4.nabble.com/Passing-a-list-of-Groovy-Object-between-Controllers-td3551395.html

loeschg
  • 29,961
  • 26
  • 97
  • 150