Hi Geert,

thanks for the info. I think your proposed solution would be a good step forward. One thing though about how to present the manytomany constraint : maybe you should offer the choice on how to show the related table items. A multi select list is the most obvious, but people might opt for checkboxes e.g. .

Thanks

Henk

Geert Bevin wrote:
Hi Henk,

this is fairly easy to implement yourself using an intermediate join table and by writing the database logic yourself. Sadly I don't really have the time to detail this step by step, but I'll probably write something about it in on of the upcoming books.

In the meantime, I'm looking into adding native support for this to RIFE and RIFE/Crud.

This is what I'm thinking about at the moment. Anyone, please feel free to give comments and ideas about how to do this best.

* add a new manyToMany(Class klass) constrain to ConstrainedProperty

The property type related to the named property should be a collection or an array of integers. It will not be mapped to a column in the table of the bean class. Instead, it will work with an intermediate join table. The name of the table is tablename1_tablename2, the names are those of the tables that are present in the many to many relationship and they are alphabetically ordered (so that reverse a manyToMany constraint on the second class would use the same link table). The link table will have two columns that have the same names as the identifier columns of linked tables, prefixed with their table name.

For example, considering your Band and Musician classes, you'd have a band_musician join table with the columns band_id and musician_id.

* the manyToMany constrained property will be auto-populated during select and contain the identifier values of the associated ids.

* during save, insert and update, these ids will be stored automatically in the join table and any previous values for the entity in the join table will be removed first.

* Delete will simply remove the correct values from the join table

* the install and remove methods will also create and remove the join table

Now, related to RIFE/Crud.

* when the manyToMany constraint is present, a multi select list will be shown for the property that uses the textual identifier (just as with manyToOne)

* when only an association constraint is present towards a manyToMany class, the textual identifier values of associated class are simply listed, and a link is present to go to each individual entity directly

What do you think of this?

Best regards,

Geert

On 19 May 2006, at 00:28, henk wrote:

Ok. I have two tables : Band and Musician. A Band contains different Musicians and a Musician can play in different Bands. So I need an interface for editing a Band in which I can choose from the list of available Musicians (e.g. a html SELECT MULTIPLE), the ones that play in this Band. It would also be nice to see in the Musician overview, in which Bands he/she plays.

Fairly simple, and I can code this from scratch. But if I can integrate this with my other Crud editors, it would be even nicer.

thanks

Henk

Geert Bevin wrote:
Hi Henk,
can you give a brief description of what your many-to-many interface should have to do?
Best regards,
Geert
On 18 May 2006, at 12:58, Henk wrote:
Hi,

I am using Rife/crud in my application and it works very nice. I even figured out how to link directly to the add and browse things so I can use my own administration interface. So far so good. The sad thing is I also need an interface which allows many-to-many relationships. I searched troughout the site and mail archives, and I understand this is not possible out-of-the-box. No problem, I don't mind to code. But I badly need an example or good advice on how to proceed. I think have to use my own element implementation. Can you point me to some example ? Sorry to ask this once again, if I find a decent way to do this, I can maybe post it somewhere.
Keep up the good work !

Henk


_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users


--
Geert Bevin             Uwyn bvba               GTalk: [EMAIL PROTECTED]
"Use what you need"     Avenue de Scailmont 34  Skype: gbevin
http://www.uwyn.com     7170 Manage, Belgium      AIM: geertbevin
gbevin at uwyn dot com  Tel: +32 64 84 80 03   Mobile: +32 477 302 599

PGP Fingerprint : 4E21 6399 CD9E A384 6619  719A C8F4 D40D 309F D6A9
Public PGP key  : available at servers pgp.mit.edu, wwwkeys.pgp.net


_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users



_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users

Reply via email to