IDE Widget Sample Dojo DatePicker

From MemberWiki

Jump to: navigation, search

The following example is adapted from the jMaki widget.json file for the Dojo datepicker widget and re-expressed in the proposed XML markup language for widgets.

jMaki's widget.json for Dojo datepicker widget

 {
    'name': 'Drop Down Date Picker',
    'type': 'dojo',
    'version' : '1.0',
    'jmakiVersion' : '1.0',    
    'image': 'images/dojo-date-picker.jpg',
    'description': 'This widget is a drop down date picker.',
    'value': {'required': false, 'type': 'DATE'},
    "args": [
        {"displayFormat":{
            "type":"STRING",
            "description":"The format of the data in MM/dd/yyyy where MM = Month, dd == day of month, and yyyy is the year",   
            "defaultValue": "MM/dd/yyyy"
            }
        }
    ],   
    'config' : {
          'type' :
           { 'id' : 'dojo', 
             'libs' : [
                   '../resources/libs/dojo/v0.4.3/djd43.js'
               ],
               'preload' : 'if (typeof djConfig ==\'undefined\') djConfig = { parseWidgets: false, searchIds: [] };',
               'resources' : [
                 '../resources/libs/dojo/v0.4.3/src'
               ]
    }, 
    'topicInfo' : {
	'type' : 'publish',
	'topicName' : '/dojo/dropdownDatePicker',
	'description' : 'Publish widget id, wargs and value selected',
    }        
  }
}

Same widget expressed in proposed XML markup language

<widget 
    xmlns="http://ns.openajax.org/widgets"
    xmlns:jmaki="http://something" <!-- at least one thing here is jMaki-specific -->
    name="Drop Down Date Picker"
    widgetVersion='1.0'
    specVersion='1.0'       <!-- i.e., version of IDE metadata spec -->  
  >
  <description>This widget is a drop down date picker.</description>
  <icons>
    <icon src=images/dojo-date-picker.jpg"/>
  </icons>
  <properties>
    <!-- FIXME: Not sure what difference there is in jMake between a 'value' and an 'arg'.
	     Treating them the same here. -->
    <property name="value" type="Date" required="true">
      <description>jMake 'value' parameter. Not sure what it does.</description>
    </property>
    <property name="displayFormat" type="String" default="MM/dd/yyyy">
      <description>The format of the data in MM/dd/yyyy where MM = Month, dd == day of month, and yyyy is the year</description>
    </property>
  </properties>
  <requires>
    <require type="library" name="dojo" minVersion="0.4.3"
             src="../resources/libs/dojo/v0.4.3/djd43.js" includeAssetReference="true">
      <preload>
        if (typeof djConfig ==\'undefined\') djConfig = { parseWidgets: false, searchIds: [] };
      </preload>
    </require>
    <require type="folder"
             src="../resources/libs/dojo/v0.4.3/src" includeAssetReference="false">
    </require>
  </requires>
  <pubsub>
    <!-- Probably need to add 'description' attribute generally, but putting it in
		jMake namespace for now because original XML grammar didn't have it. -->
    <publishesTo topic="/dojo/dropdownDatePicker">
	  <jmaki:description>Publish widget id, wargs and value selected"</jmaki:description>
	</publishesTo>
  </pubsub>
</widget>
Personal tools