Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

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

0 votes

Comments

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.)

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

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
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];
           },
       
    });
})();

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 85
× 58
× 35
× 34

Question asked: Jul 26 '12, 4:04 p.m.

Question was seen: 6,615 times

Last updated: Sep 08 '14, 9:07 a.m.

Confirmation Cancel Confirm