1 Reply Latest reply on Jun 11, 2017 10:27 PM by anna RSS
    旭王 Newbie

    how to specify the template?

    I am not very understanding of this,how to specify the template?


      • Re: how to specify the template?
        anna Communicator

        Dear 旭王,

        Firstly I believe you have already setup your Extension project with "New Extension Project" option(this is on the prerequisite that you have already installed ThingWorx extension eclipse plugin from Marketplace), if not you need to manually add a new project and organize your project folders that is compatible with Extension's requirement(for exmaple, you should add src,configfiles,lib,etc.)

        and then please follow the given example in our developer guide - HelloWorld Example. Basically it is authored like:

        1. Create a new java class name with HelloWorldThing and extends with com.thingworx.things.Thing, and configure the property, service, event definition which are needed per your requirement

        2. Edit metadata.xml:

        this is a sample:

          <ExtensionPackage name="HelloWorld_Extension"
                description="HelloWorld Extension. Sample extension."
                vendor="ThingWorx Customer Service"
                minimumThingWorxVersion="5.0.0" >
            <FileResource type="JAR" file="thingworx-helloworld-extension.jar" description="HelloWorld ThingPackage JAR" />
          <ThingPackage name="HelloWorldThing" description="Sample Extension" className="com.helloinc.things.helloworld.HelloWorldThing" aspect.isSystemObject="false" aspect.isCreatable="true" />
          <ThingPackage name="GoodByeThing" description="Sample Extension" className="com.helloinc.things.goodbye.GoodByeThing" aspect.isSystemObject="false" aspect.isCreatable="true" />
          <ThingTemplate name="HelloWorld" description="HelloWorld Template" thingPackage="HelloWorldThing" aspect.isSystemObject="false">
          <ThingTemplate name="GoodBye" description="GoodBye Template" thingPackage="GoodByeThing" aspect.isSystemObject="false">
          <DataShape name="SalutationSentEvent" description="Hello World salutation event" aspect.isSystemObject="false">
            <FieldDefinition name="userGreeted" description="Name of user receiving the salutation" baseType="STRING" aspect.isPrimaryKey="true"/>


        Notice that in the ThingTemplates node in metadata.xml, we have HelloWorld setting as the template and HelloWorldThing as the ThingPackage, so after importing your extension into Thingworx, you will see there is HelloWorld ThingTemplate in ThingWorx Composer.


        I hope it will help you.