UIEvolutin Inc.
UJML Language Reference
reference

A Reference Type is an opaque value used to reference an instance of a component.

Reference types are raw references to an instance of a component. Unlike interface types you cannot use them to access component methods or handle component events unless you first cast the reference type to a valid interface type. See Interface Types. The actual reference is the opaque values returned when you create an instance of a component using the _createInstance() function. _createInstance() function

Reference types in UJML 

In UJML, a reference is a data type with the value stored as a component instance in memory. You can assign a reference variable to another variable. See Variables. You can pass a reference value as a function argument and return one from a function. You can tell a reference to paint itself using the display-instance element. See display-instance. You can cast a reference to an interface type if the reference is null or if the component instance implements that interface. See Interface Types. But you cannot convert a reference type to a different data type or use it in an expression, other than casting to an interface type. See Expressions. State variables may not be of the reference type.

Casting reference types

The _castInterface() function converts a reference value to a specific interface type. See _castInterface() function.

Comparing reference types

You can compare two reference type variables to see if they refer to the same component instance using the _isSameInstance() function. See _isSameInstance() function.

Reflecting reference types

You can determine if an reference type instance refers to a component that implements a specific interface using the _instanceOf() function. See _instanceOf() function.

Reference types and 'null'

References may be a special value called 'null'. When a reference is null, it does not refer to any extension instance. It is, essentially, empty. You can test to see if a reference is null by using the _is_null() function. See _is_null() function. You can also assign the literal value 'null' to a reference variable to give the variable the value null.

Reference literals

Because references are an opaque type, there is no such thing as a reference literal except for the value 'null'. See Literals and Constants.

The following example declares a reference variable. It is part of the things.ujml sample.

<var name="ref" type="reference"/>

 

The following assigns a value returned from a component method to the reference variable declared above. It is part of the things.ujml sample.

ref = mThingEnumerator.getNextItem();

 

The following example shows how to cast the reference variable declared above to an interface type. It is part of the things.ujml sample.

thing = _castInterface(ref, "IThing");
Copyright (c) 2000-2007 UIEvolution, Inc. All rights reserved.
What do you think about this topic? Send feedback!