How is 'id' property of scaffold pages mapped?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How is 'id' property of scaffold pages mapped?

marcopas
Hi there,

coming from some older versions of Grails i am trying to wrap my head around the 'id' property of objects in the scaffold pages.

In previous version of Grails the object id was often generated as a hiddenField inside the HTML, but checking the generated pages now i cannot find them anywhere.

How is the mapping between pages/objects and actions currently done?

The reasons behind my question is when i try to leave out the hiddenField (id) in custom build pages i get new records when doing updates instead of performing an actual update.

--
Marco Pas
Reply | Threaded
Open this post in threaded view
|

Re: How is 'id' property of scaffold pages mapped?

Jeff Scott Brown-2


On January 29, 2014 at 1:58:45 PM, Marco Pas ([hidden email]) wrote:

>  
> Hi there,
>  
> coming from some older versions of Grails i am trying to wrap my  
> head
> around the 'id' property of objects in the scaffold pages.
>  
> In previous version of Grails the object id was often generated  
> as a
> hiddenField inside the HTML, but checking the generated pages  
> now i cannot
> find them anywhere.
>  
> How is the mapping between pages/objects and actions currently  
> done?
>  
> The reasons behind my question is when i try to leave out the hiddenField  
> (id) in custom build pages i get new records when doing updates  
> instead of
> performing an actual update.
>  
> --
> Marco Pas

If you look in a default generated edit.gsp, for example, you should see code that looks something like this:

<g:form url="[resource:personInstance, action:'update']">
 …
</g:form>

That will generate markup which looks something like this:

<form action=“/myappname/person/update/1">
   …
</form>

With the default URL mappings in place that form will submit to the update action in the PersonController and the “id” request parameter will have a value of “1”.

Does that answer your questions or not?



JSB


Jeff Scott Brown
[hidden email]

Autism Strikes 1 in 166  
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: How is 'id' property of scaffold pages mapped?

marcopas
Thanks! It indeed answers my question!


2014-01-29 Jeff Scott Brown <[hidden email]>:


On January 29, 2014 at 1:58:45 PM, Marco Pas ([hidden email]) wrote:
>
> Hi there,
>
> coming from some older versions of Grails i am trying to wrap my
> head
> around the 'id' property of objects in the scaffold pages.
>
> In previous version of Grails the object id was often generated
> as a
> hiddenField inside the HTML, but checking the generated pages
> now i cannot
> find them anywhere.
>
> How is the mapping between pages/objects and actions currently
> done?
>
> The reasons behind my question is when i try to leave out the hiddenField
> (id) in custom build pages i get new records when doing updates
> instead of
> performing an actual update.
>
> --
> Marco Pas


If you look in a default generated edit.gsp, for example, you should see code that looks something like this:

<g:form url="[resource:personInstance, action:'update']">
 …
</g:form>

That will generate markup which looks something like this:

<form action=“/myappname/person/update/1">
   …
</form>

With the default URL mappings in place that form will submit to the update action in the PersonController and the “id” request parameter will have a value of “1”.

Does that answer your questions or not?



JSB


Jeff Scott Brown
[hidden email]

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Marco Pas