UIEvolutin Inc.
UJML Language Reference
Component Files

A component file contains a UJML component that is loaded at run time and zero or more instances created.

Component files have a file extension of '.ujml'. For example, 'foo.ujml'. A component file contains a ujml root element, which contains a component element. See Layout of UJML Files, Byte Code Files, ujml, component

Component files are compiled to byte code. See Byte Code Files. A compiled component is loaded by a UJML application or partition using a resource element. See Components, Resources. Instances of the component may then be created and destroyed. See Components.

The following example is a component file implementing a 'thing' that is an 'animal'. It is part of the Things sample.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ujml PUBLIC "-//UIEVOLUTION//DTD UJML 2.0//EN" "ujml-2.0.dtd"[]>
<!--
  Copyright (c) 2000-2007 UIEvolution, Inc.
  http://www.uievolution.com
-->
<!--
    animal.ujml

    Animal 'thing' component.
-->
<ujml>
    <interfaces>
        <include file="ithings.ujmi"/>
    </interfaces>

    <component name="Animal">
        <interfaces>
            <interface name="IThing" access="export"/>
            <interface name="IAnimal" access="export"/>
        </interfaces>

        <variables>
            <var name="mName" type="string"/>
            <var name="mDescription" type="string"/>
            <var name="mImageName" type="string"/>
            <var name="mStringVal" type="string"/>
            <var name="mBooleanVal" type="boolean"/>
        </variables>

        <functions>
            <!--
                Gets the name of the thing.
            -->
            <function name="IThing.getName" type="string">
                <return><eval>mName</eval></return>
            </function>

            <!--
                Gets a description of the thing.
            -->
            <function name="IThing.getDescription" type="string">
                <return><eval>mDescription</eval></return>
            </function>
            <!--
                Gets the image URL of the thing.
            -->
            <function name="IThing.getImageName" type="string">
                <return><eval>mImageName</eval></return>
            </function>

            <!--
               Initializes the thing.
            -->
            <function name="IAnimal.init" type="void">
                <parameters>
                    <var name="name" type="string"/>
                    <var name="description" type="string"/>
                    <var name="imgName" type="string"/>
                    <var name="sound" type="string"/>
                    <var name="isDomesticated" type="boolean"/>
                </parameters>
                <script>
                    mName = name;
                    mDescription = description;
                    mImageName = imgName;
                    mStringVal = sound;
                    mBooleanVal = isDomesticated;
                </script>
            </function>
            <!--
                Gets the sound the thing makes.
            -->
            <function name="IAnimal.getSound" type="string">
                <return><eval>mStringVal</eval></return>
            </function>
            <!--
                Gets a boolean value indicating if the thing is a
                vertebrate.
            -->
            <function name="IAnimal.getIsDomesticated" type="boolean">
                <return><eval>mBooleanVal</eval></return>
            </function>
        </functions>
    </component>
</ujml>
Copyright (c) 2000-2007 UIEvolution, Inc. All rights reserved.
What do you think about this topic? Send feedback!