GSP Tag : Select

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

GSP Tag : Select

Beaur, Remi
Hello,

I'm encountering a problem with the "select" gsp tag. For example, how
can you modify an automatically generated (by scaffolding) gsp view to
make it show the options by their name rather than by their id
(supposing the object has a name attribute). Of course, I want the form
to continue returning the id of the selected option (not the name). I
suppose that can be easily done with "optionValue/optionKey" but all my
attempts failed.

Thanks
Rémi Béaur
Reply | Threaded
Open this post in threaded view
|

Re: GSP Tag : Select

Richard Bleachley
Hi Remi,

Did you try to generate the controller and view for your scaffolding controller? You can use this by issueing the 'grails generate-all' command, passing in the name of your controller. From there on you can modify your view in any way you want.

Hope this helps

Richard

On 4/18/06, Beaur, Remi <[hidden email]> wrote:
Hello,

I'm encountering a problem with the "select" gsp tag. For example, how
can you modify an automatically generated (by scaffolding) gsp view to
make it show the options by their name rather than by their id
(supposing the object has a name attribute). Of course, I want the form
to continue returning the id of the selected option (not the name). I
suppose that can be easily done with "optionValue/optionKey" but all my
attempts failed.

Thanks
Rémi Béaur

Reply | Threaded
Open this post in threaded view
|

Re: GSP Tag : Select

Richard Bleachley
Hi Remi,

You should pass the name of your domain class, not the name of the controller.

Richard

On 4/18/06, Richard Bleachley <[hidden email]> wrote:
Hi Remi,

Did you try to generate the controller and view for your scaffolding controller? You can use this by issueing the 'grails generate-all' command, passing in the name of your controller. From there on you can modify your view in any way you want.

Hope this helps

Richard


On 4/18/06, Beaur, Remi <[hidden email]> wrote:
Hello,

I'm encountering a problem with the "select" gsp tag. For example, how
can you modify an automatically generated (by scaffolding) gsp view to
make it show the options by their name rather than by their id
(supposing the object has a name attribute). Of course, I want the form
to continue returning the id of the selected option (not the name). I
suppose that can be easily done with "optionValue/optionKey" but all my
attempts failed.

Thanks
Rémi Béaur


Reply | Threaded
Open this post in threaded view
|

Re: GSP Tag : Select

Beaur, Remi
In reply to this post by Beaur, Remi
Hi Richard,

I was precisely using auto-generated controllers and views.

For example, here is a piece of the generated view :

<g:select optionKey="id" from="${Project.list()}" name='project.id'
value='${projectUserRelation?.project?.name}'></g:select>

I would like the "Project" list to be shown by "name" (rather than by
"id" as it is), but the value returned should still be the "id" (not the
"name"). I tried to use "OptionValue/OptionKey" but I must not
understand what are their use .

Thanks
Rémi Béaur


Richard Bleachley a écrit :

> Hi Remi,
>
> Did you try to generate the controller and view for your scaffolding
> controller? You can use this by issueing the 'grails generate-all'
> command, passing in the name of your controller. From there on you can
> modify your view in any way you want.
>
> Hope this helps
>
> Richard
>
>
> On 4/18/06, Beaur, Remi <[hidden email]
> <mailto:[hidden email]> > wrote:
>
> Hello,
>
> I'm encountering a problem with the "select" gsp tag. For example, how
> can you modify an automatically generated (by scaffolding) gsp view to
> make it show the options by their name rather than by their id
> (supposing the object has a name attribute). Of course, I want the form
> to continue returning the id of the selected option (not the name). I
> suppose that can be easily done with "optionValue/optionKey" but all my
> attempts failed.
>
> Thanks
> Rémi Béaur
>
>
>
> .
>
>  
Reply | Threaded
Open this post in threaded view
|

Re: GSP Tag : Select

graemer
On 4/18/06, Beaur, Remi <[hidden email]> wrote:
> Hi Richard,
>
> I was precisely using auto-generated controllers and views.
>
> For example, here is a piece of the generated view :
>
> <g:select optionKey="id" from="${Project.list()}" name='project.id'
> value='${projectUserRelation?.project?.name}'></g:select>

Actually the above doesn't use the id it calls "toString()" on each
instance in the list so you have 2 options you could implement
toSTring to return the name of the project or you could set the
'optionValue' to 'name'

Graeme

>
> I would like the "Project" list to be shown by "name" (rather than by
> "id" as it is), but the value returned should still be the "id" (not the
> "name"). I tried to use "OptionValue/OptionKey" but I must not
> understand what are their use .
>
> Thanks
> Rémi Béaur
>
>
> Richard Bleachley a écrit :
> > Hi Remi,
> >
> > Did you try to generate the controller and view for your scaffolding
> > controller? You can use this by issueing the 'grails generate-all'
> > command, passing in the name of your controller. From there on you can
> > modify your view in any way you want.
> >
> > Hope this helps
> >
> > Richard
> >
> >
> > On 4/18/06, Beaur, Remi <[hidden email]
> > <mailto:[hidden email]> > wrote:
> >
> > Hello,
> >
> > I'm encountering a problem with the "select" gsp tag. For example, how
> > can you modify an automatically generated (by scaffolding) gsp view to
> > make it show the options by their name rather than by their id
> > (supposing the object has a name attribute). Of course, I want the form
> > to continue returning the id of the selected option (not the name). I
> > suppose that can be easily done with "optionValue/optionKey" but all my
> > attempts failed.
> >
> > Thanks
> > Rémi Béaur
> >
> >
> >
> > .
> >
> >
>