It's all about the answers!

Ask a question

Is this a problem with dojo? Custom widget woes...


David Claborn (112) | asked Jul 26 '12, 4:04 p.m.
edited Jul 26 '12, 4:24 p.m.
Hi,

I'm currently building a Jazz application (in RTC) where I'm trying to define a custom widget with dojo in the Jazz Web UI.
A partial declaration is below (note the ellipsis are shorthand for something that might be confidential):

**Note : this is on JTS 4.0 with dojo 1.6.1**

dojo.declare("com.ibm.team.dev.proto.web.StrategicObjectiveTest", [ dijit._Widget, dijit._Templated], {
         templateString: '<div><h1>Strategic Objectives with Jazz Web UI</h1><h1 dojoAttachPoint="label"></h1><div dojoType="..." id="..." style="width: 600px; height: 600px;"/><div id="filters"></div><div id="tab"></div></div>'

**edit: tags in bold so that the templateString doesn't get parsed as html.

This seems to work fine when the parameter ?debug=true is passed through the browser, but when I remove the ?debug=true, nothing works.  I wrapped the dojo.declare in a dojo.addOnLoad() call and found out that it never gets triggered.  I removed my dojo.require() statements one by one to figure out which one was failing to be resolved by the loader, and it turns out that it's happening when I require "digit._Templated" (which requires "dojo.parser").  I enabled "break on all errors" in  firebug and received this error:
parent.clsInfo.cls.prototype is undefined which happens in parser.js.  I'm guessing it's trying to parse my widget, but I don't understand why it's being thrown or how to fix it.

I haven't touched any of the dojo code, so I'm unsure of what my next step should be.  Is this a problem with dojo?  I've searched around the forums and haven't found anything that's resolved this issue, so any form of guidance would be appreciated.

Thanks,
David

Comments
Ginny Ghezzo commented Apr 02 '14, 2:26 p.m.
JAZZ DEVELOPER

David,
Did you ever get this working?   (I came across it trying to bootstrap myself to create a new version of the "Work Item Statistics" so it counts as contains instead of is.)


Jonas Studer commented Jul 24 '14, 10:42 a.m.

Hy David,

If you want, I could give you an empty class for a widget with all needed functions described.
And feel free to ask more :D


Jonas Studer commented Jul 25 '14, 4:35 a.m.

Hy Dave,

Due to my research about your error I got this.

http://dojotoolkit.org/reference-guide/1.10/dijit/_Templated.html
There they say, they gonna remove it. So it might not exists anymore, so it could not be loaded.

"Deprecated mixin for widgets that are instantiated from a template. Widgets should use _TemplatedMixin plus if necessary _WidgetsInTemplateMixin instead."

One answer



permanent link
Jonas Studer (207917) | answered Jul 24 '14, 10:54 a.m.
edited Sep 08 '14, 9:07 a.m.
Hy David,

So here's my descripted class. It might help.
Due to this display, you can write me, and I gonna mail you this class.

//Provide is the name of your Widget
dojo.provide("com.siemens.bt.jazz.absence.viewlet.web.AbsencesViewlet");

//Requirements
dojo.require("com.ibm.team.dashboard.web.ui.Viewlet"); //This one is the superclass of RTC Widgets
dojo.require("my.OtherClass")

//This is standard
(function() {

    //Make these strings global avayable //Its easyer to instantiate Objects this way
    var Viewlet = com.ibm.team.dashboard.web.ui.Viewlet;
    var OtherClass = my.OtherClass
   
    //Again the name of your widget in the declare
    //"Viewlet" leads to superclass
    dojo.declare("com.siemens.bt.jazz.absence.viewlet.web.AbsencesViewlet", Viewlet, {
       
        //Here's the path to your template //Mostly my templates are a simple <div><div> //I fill it always with JS
        templatePath: dojo.moduleUrl("com.siemens.bt.jazz.absence.viewlet.web", "templates/AbsencesViewlet.html"),
       

        //This Method is the first which is fired
        //But just ONE time! The first time ;)
        init: function() {
            console.log("Init absence widget");
        },
       
        //This is the second Method it fires automaticaly
        //If you use page-refresh this method is fired
        refresh: function() {
            console.log("Refresh absence widget");
        },
         
        //This fires when you maximize or minimize your widget
        update: function() {
            console.log("update absence widget");
        },
       
        //This Method isn't default, but If you wanna work with UUID it's pretty usefull
        _isValidUUID: function(value) {
            // See com.ibm.team.repository.common.UUID.validateUUID(char[])
            // e.g. _H9EB5esEEdycivs5PH0c-g
            // A valid UUID must:
            // * Have a fixed length of 23 characters
            // * Start with an underscore character
            // * Contain characters only in the range of the MIME64 encoding
            //   (Not checked for performance reasons)
            if (value &&
                (value.length === 23) &&
                (value.charAt(0) === "_")) {
                return true;
            }
            return false;
        },
       
        //VERY VERY Important Method!
        //Here you can track when you made changes in the "settings" Panel
        settingsChanged: function(oldSettings, newSettings) {
            //Check if the new settings are uneven to the old ones
            if (oldSettings.preferences.mySetting != newSettings.preferences.mySetting) {
                //Do what you need to do
            }
        },

           //Fires ONCE when the "settings"-Panel is opened
        //This one is very important if you wanna make some custom settings
        //Then you have to adress it here
           getPreferenceProvider: function(/* string */ preferenceId) {
            if (!this._preferenceProviders)
                this._preferenceProviders = {};
            if (!this._preferenceProviders[preferenceId]) {
                if(preferenceId == "MySpecialSetting"){
                    //Be sure you've made a Preference provider
                    this._preferenceProviders[preferenceId] = new MySpecialSetting({ prefId: preferenceId});
                } else {
                    this._preferenceProviders[preferenceId] = null;
                }
            }
            return this._preferenceProviders[preferenceId];
           },
       
    });
})();

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.