Passing collections between forms

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Passing collections between forms

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:22 pm

by synergos >> Wed, 26 Mar 2003 7:24:37 GMT

We have a view form which allows the user to sort a class by a number of collections (some are mkd some are dyna dictionaries).

We were wondering how to pass the active collection through to the edit form to enable the user to navigate through the collection while in the edit form using the current active collection?

We have tried to create a collection class at the form level but Jade objects to this. Is there some way in which we can set the collection once only at the view (list) form level and allow other forms (eg edit form, print form) to use the same collection?
Currently we get an error code 6093 which we cannot get around?

Steve

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Passing collections between forms

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:22 pm

by allistar >> Wed, 26 Mar 2003 8:28:04 GMT

I'm not 100% I follow your issue, but these suggestions may help:

Can you pass through the parent object of the collection to the edit form instead and then access the collection off that? If the name of the collection is not known at run time you could always store the parent object of the collection and the name of the collection property (as a String) and then do a:

collection := parentObject.getPropertyValue(collectionPropertyName).Collection;

Alternatively if you know the collection won't contain too many objects you could always copy it to a transient collection and then pass that around.

You can't store a reference to an exclusive collection, so is there a way you could design this so the collection is not exclusive (may not be appropriate depending on your design)?

You could also store a reference to the view form on the edit form, and write a method on the view form called "getCollection():Collection" which you then call from the edit form to access the collection: myViewForm.getCollection();

Hope this helps in some way,
Allistar.

------------------------------------------------------------------
Allistar Melville
Software Developer, Analyst allistar@silvermoon.co.nz
Auckland, NEW ZEALAND

Silvermoon Software
Specialising in JADE development and consulting
Visit us at: http://www.silvermoon.co.nz ------------------------------------------------------------------

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Passing collections between forms

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:22 pm

by cdshearer >> Wed, 26 Mar 2003 8:55:28 GMT

The problem you are having is that you are not allowed to assign an exclusive collection to another object... exclusive collections may only "belong" to a single parent object, so JADE prevents you from storing a reference to an exclusive collection belonging to another object.

I used to think this was just something that JADE prevented and that a relaxation of the "rules" in certain circumstances would be in order. However, the actual reference to an exclusive collection is physically a different size to a normal object reference - I think it is 10 bytes instead of 8, so an exclusive collection reference simply can't be held in a normal object reference. So, there's no way around this... except that there is a hacky workaround!

What you can do is create an Iterator on the collection, and pass this around. Then, when you want to get the actual collection reference in a method, call iterator.getCollection() and you get the collection back. Neat huh?

Hope that helps...

Craig

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Passing collections between forms

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:22 pm

by synergos >> Thu, 27 Mar 2003 1:48:11 GMT

Thanks Craig, your suggestion worked!

Steve


Return to “General Discussion”

Who is online

Users browsing this forum: Bing [Bot] and 28 guests