Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Variable Handles

1 view
Skip to first unread message

Sean Thomas

unread,
Jan 10, 2006, 3:34:54 PM1/10/06
to
If I wish to bind a list of objects to a control that have not
originated from an EcoSpace then do I use a Variable Handle?

If so what is the correct way to add an object to a Variable Handle?

Kind regards

Sean

Jonas Hogstrom [Borland]

unread,
Jan 11, 2006, 6:19:42 PM1/11/06
to
Sean Thomas wrote:

> If I wish to bind a list of objects to a control that have not
> originated from an EcoSpace then do I use a Variable Handle?

if they did not come from an EcoSpace, where did they come from? Are
they Eco objects? If they are eco objects, and you simply got them from
some piece of code, then yes, the VariableHandle should work to get
them into the UI. Set the StaticValueTypeName of the VariableHandle to
"Collection(MyClass)", and then you should be able to add object like
this:

(myVariableHandle.Element as IObjectList).Add(myObject.AsIObject)

/Jonas

Jan Nordén [Borland]

unread,
Jan 12, 2006, 12:07:24 AM1/12/06
to
Sean Thomas wrote:

If you want to databind objects that are not ECO objects, that is
totally a non-ECO issue. Can you describe what you want to do in some
more detail?

--
Jan Nordén
Senior Software Architect
MDA products group

Sean Thomas

unread,
Jan 12, 2006, 2:33:56 AM1/12/06
to
Hi Jan and Jonas

Thanks for the replies.

Yes, all the objects are ECO objects.

I have some complex filtering criteria that I wish to apply to a set of
objects that are retrieved via an ExpressionHandle. Looping through the
objects in the ExpressionHandle is fine.

Once I have selected my subset of ECO objects I wish to bind them to a
list object so I can use CurrencyManagerHandles etc.

I had already tried the following:

(vhTest.Element as IObjectList).Add(AssignedPA.AsIObject());

But get a null reference exception. Is there something I am required to
do other than drop a VariableHandle on the form and reference it?

While experimenting I discovered that if I attempted to access a
ExpressionHandle in exactly the same way as above then:
1. If the ExpressionHandle had valid a OCL Expression then whatever I
added was simply ignored.
2. If the OCL Expression was blank then I got the same error as received
with the VariableHandle.

Using 2006 Architect by the way.

Kind regards

Sean

Jan Nordén [Borland]

unread,
Jan 12, 2006, 2:20:59 AM1/12/06
to
Sean Thomas wrote:

> Hi Jan and Jonas
>
> Thanks for the replies.
>
> Yes, all the objects are ECO objects.
>
> I have some complex filtering criteria that I wish to apply to a set
> of objects that are retrieved via an ExpressionHandle. Looping
> through the objects in the ExpressionHandle is fine.
>
> Once I have selected my subset of ECO objects I wish to bind them to
> a list object so I can use CurrencyManagerHandles etc.
>
> I had already tried the following:
>
> (vhTest.Element as IObjectList).Add(AssignedPA.AsIObject());
>
> But get a null reference exception. Is there something I am required
> to do other than drop a VariableHandle on the form and reference it?
>

At designtime:

Set EcoSpaceType
set StatitValueTypeName to Collection(<YourClassName>)

at runtime:

Set the EcoSpace property the same way it is set for rhRoot.

Sean Thomas

unread,
Jan 12, 2006, 3:11:54 PM1/12/06
to
Hi Jan

I have now set the EcoSpace property as:

vhTest.EcoSpace = ecoSpace;

The EcoSpaceType and StaticValueTypeName are also set. I still get the
same Null Reference exception.

Any ideas?

Kind regards

Sean

Jan Nordén [Borland]

unread,
Jan 12, 2006, 2:23:11 PM1/12/06
to
Sean Thomas wrote:

> Hi Jan
>
> I have now set the EcoSpace property as:
>
> vhTest.EcoSpace = ecoSpace;
>
> The EcoSpaceType and StaticValueTypeName are also set. I still get
> the same Null Reference exception.
>
> Any ideas?
>
> Kind regards
>
> Sean
>

Hm,

ECO II or ECO III?

I believe there was a problem with setting the VariableHandle to a
Collection type in ECO II.

What do you get if you look at myVariableHandle.Element in the
dubugger? Is it null, and if not, what type is it?

Sean Thomas

unread,
Jan 12, 2006, 5:51:51 PM1/12/06
to
Hi Jan

ECOIII and loving it! I am getting a null reference. The contents of
the watch list follow.

Watch Name Value
vhTest.Element {null reference, UmlClassImpl&, ObjectNullImpl&}

Kind regards

Sean

Jan Nordén [Borland]

unread,
Jan 12, 2006, 11:22:50 PM1/12/06
to
Sean Thomas wrote:

Can you post or mail me the application?

Sean Thomas

unread,
Jan 13, 2006, 5:09:10 PM1/13/06
to
Hi Jan

I have posted a very simple application to borland.public.attachments
titled "VariableHandle Demo for Jan".

I look forward to the solution, I must be doing something wrong...

Jan Nordén [Borland]

unread,
Jan 16, 2006, 9:08:22 AM1/16/06
to
Sean Thomas wrote:


It is indeed a bug in the handling of collections in the
variableHandle. Thanks for finding it.

You can get around it by using a ReferenceHandle instead.

rhObjects should be configured as:

EcoSpaceType = VariableHandleDemo.VariableHandleDemoEcoSpace)
StaticValueTypeName = "Collection(Test)

and the following code added to the constructor (which does exactly
what the variablehandle should be doing):

rhObjects.EcoSpace = m_EcoSpace;
IVariableFactoryService vfs =
EcoServiceHelper.GetVariableFactoryService(m_EcoSpace);
rhObjects.SetElement(vfs.CreateTypedObjectList(typeof(Test), false));

Sean Thomas

unread,
Jan 18, 2006, 1:52:37 AM1/18/06
to
Hi Jan

Thank you very much for the help. I finally got around to implementing
your suggestion. Your suggested approach is working very well.

Jan Nordén [Borland]

unread,
Jan 18, 2006, 4:37:40 AM1/18/06
to
Jan Nordén [Borland] wrote:

> Sean Thomas wrote:
>
> > Hi Jan
> >
> > I have posted a very simple application to
> > borland.public.attachments titled "VariableHandle Demo for Jan".
> >
> > I look forward to the solution, I must be doing something wrong...
> >
> > Kind regards
> >
> > Sean
> >
> > Jan Nordén [Borland] wrote:
> > > Can you post or mail me the application?
>
>
> It is indeed a bug in the handling of collections in the
> variableHandle. Thanks for finding it.
>

RAID 238378.

0 new messages