One-to-Many Self Referencing - Dynamic Scaffolding

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

One-to-Many Self Referencing - Dynamic Scaffolding

Paul McKinney
I have a domain and controller that looks like:

class Category
{
        static hasMany = [subcategories:Category]

        String name

}

class CategoryController
{
        def scaffold = Category
}



When I test this out using scaffolding I am able to save a parent Category and then it gives me a link to create the
subcategories.  After I create a subcategory I come back to the parent Category and I don't see the subcategory listed
under the first parent Category I created.

I'm just started learning Grails so maybe I'm just doing something wrong or I have a fundamental misunderstanding as
to how I thought the scaffolding should work.  I'm using Grails 0.5.  Is this just a scaffolding issue or is is there
an issue with self-referencing classes?  Any insight would be appreciated.  Thanks.





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

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: One-to-Many Self Referencing - Dynamic Scaffolding

graemer
I don't believe scaffolding works with circular one-to-many relationships

Cheers

On 6/6/07, Paul McKinney <[hidden email]> wrote:

> I have a domain and controller that looks like:
>
> class Category
> {
>         static hasMany = [subcategories:Category]
>
>         String name
>
> }
>
> class CategoryController
> {
>         def scaffold = Category
> }
>
>
>
> When I test this out using scaffolding I am able to save a parent Category and then it gives me a link to create the
> subcategories.  After I create a subcategory I come back to the parent Category and I don't see the subcategory listed
> under the first parent Category I created.
>
> I'm just started learning Grails so maybe I'm just doing something wrong or I have a fundamental misunderstanding as
> to how I thought the scaffolding should work.  I'm using Grails 0.5.  Is this just a scaffolding issue or is is there
> an issue with self-referencing classes?  Any insight would be appreciated.  Thanks.
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Graeme Rocher
Grails Project Lead
http://grails.org

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

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

RE: One-to-Many Self Referencing - Dynamic Scaffolding

Dierk König
well, and you only have one-directional one-to-many relation
and scaffolding only works for bi-directional ones, right?
So at least you would need a
 Category parent
or such and probably  
 static belongsTo = Category
 static contraints = {
     parent(nullable: true)
 }
to make this work (but not totally sure...)

ciao
Dierk

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]On Behalf
> Of Graeme Rocher
> Sent: Mittwoch, 6. Juni 2007 22:09
> To: [hidden email]
> Subject: Re: [grails-user] One-to-Many Self Referencing - Dynamic
> Scaffolding
>
>
> I don't believe scaffolding works with circular one-to-many relationships
>
> Cheers
>
> On 6/6/07, Paul McKinney <[hidden email]> wrote:
> > I have a domain and controller that looks like:
> >
> > class Category
> > {
> >         static hasMany = [subcategories:Category]
> >
> >         String name
> >
> > }
> >
> > class CategoryController
> > {
> >         def scaffold = Category
> > }
> >
> >
> >
> > When I test this out using scaffolding I am able to save a
> parent Category and then it gives me a link to create the
> > subcategories.  After I create a subcategory I come back to the
> parent Category and I don't see the subcategory listed
> > under the first parent Category I created.
> >
> > I'm just started learning Grails so maybe I'm just doing
> something wrong or I have a fundamental misunderstanding as
> > to how I thought the scaffolding should work.  I'm using Grails
> 0.5.  Is this just a scaffolding issue or is is there
> > an issue with self-referencing classes?  Any insight would be
> appreciated.  Thanks.
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
>
>
> --
> Graeme Rocher
> Grails Project Lead
> http://grails.org
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email

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

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

RE: One-to-Many Self Referencing - Dynamic Scaffolding

Paul McKinney
Dierk, what you suggested creates a more appropriate looking table and should work great for what I am planning.

Thanks again for the suggestion.

Paul

> well, and you only have one-directional one-to-many relation
> and scaffolding only works for bi-directional ones, right?
> So at least you would need a
>  Category parent
> or such and probably
>  static belongsTo = Category
>  static contraints = {
>      parent(nullable: true)
>  }
> to make this work (but not totally sure...)
>
> ciao
> Dierk
>
>> -----Original Message-----
>> From: [hidden email] [mailto:[hidden email]]On Behalf
>> Of Graeme Rocher
>> Sent: Mittwoch, 6. Juni 2007 22:09
>> To: [hidden email]
>> Subject: Re: [grails-user] One-to-Many Self Referencing - Dynamic
>> Scaffolding
>>
>>
>> I don't believe scaffolding works with circular one-to-many relationships
>>
>> Cheers
>>
>> On 6/6/07, Paul McKinney <[hidden email]> wrote:
>> > I have a domain and controller that looks like:
>> >
>> > class Category
>> > {
>> >         static hasMany = [subcategories:Category]
>> >
>> >         String name
>> >
>> > }
>> >
>> > class CategoryController
>> > {
>> >         def scaffold = Category
>> > }
>> >
>> >
>> >
>> > When I test this out using scaffolding I am able to save a
>> parent Category and then it gives me a link to create the
>> > subcategories.  After I create a subcategory I come back to the
>> parent Category and I don't see the subcategory listed
>> > under the first parent Category I created.
>> >
>> > I'm just started learning Grails so maybe I'm just doing
>> something wrong or I have a fundamental misunderstanding as
>> > to how I thought the scaffolding should work.  I'm using Grails
>> 0.5.  Is this just a scaffolding issue or is is there
>> > an issue with self-referencing classes?  Any insight would be
>> appreciated.  Thanks.
>> >
>> >
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe from this list please visit:
>> >
>> >     http://xircles.codehaus.org/manage_email
>> >
>> >
>>
>>
>> --
>> Graeme Rocher
>> Grails Project Lead
>> http://grails.org
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>



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

    http://xircles.codehaus.org/manage_email