Modern Dojo(AMD Notation) causing troubles (Widget creation) with IBM Modules
Dear Community,
I've got a little question about the modern dojo... And it's usage. 1: Till now I've created widgets this way: dojo.provide("my.own.viewlet.web.Widget"); //This one is the Dashboardsuperclass, dojo.require("com.ibm.team.dashboard.web.ui.Viewlet"); //Bsp: of requirements dojo.require("dijit.MenuBar"); (function() { var Viewlet = com.ibm.team.dashboard.web.ui.Viewlet; var MenuBar = dijit.MenuBar; //My Widget inhertits from the Viewlet dojo.declare("my.own.viewlet.web.Widget", Viewlet, { templatePath: dojo.moduleUrl("my.own.viewlet.web", "templates/template.html"), 2: But with the new AMD Notation I can't require the Viewlet anymore... why that? It doesn't even load itself... and how would I set it as parent class? define([ "dojo/_base/declare", "dijit/_WidgetBase", "dijit/MenuBar", "com.ibm.team.dashboard.web.ui.Viewlet", ], function(declare, _WidgetBase, Viewlet, MenuBar) { return declare("my.own.viewlet.web.TestAmd", _WidgetBase, { 3: Not even the separate require won't load this thing require(["com.siemens.bt.jazz.absence.viewlet.web.AbsencesViewlet"], function(ViewletTwo){ console.log("Inside Require"); console.log(ViewletTwo); }); Please help me |
2 answers
Hy there fellas,
I stumbled across this old question. Now I have the solution for you. The problem we have here is, that all of the IBM-Javascript-Classes are written in an old dojo version (at least they use the old syntax [Dojo < 1.7]) Therefore, if you use the AMD-Notations you'll get an "error" when you require old "Classes". Here I show you the header of an AMD-Defined Widget. I'm requiring the external Class "com.ibm.team.dashboard.web.ui.Viewlet". This will fire this errorMessage: "Unresolved module with id: com.ibm.team.dashboard.web.ui.Viewlet" And the attribute "Viewlet" between declare and domAttr will be EMPTY! But you still can use it with "dojo.global". dojo.global.com.ibm.team.dashboard.web.ui.Viewlet This will do the trick. define(["dojo/_base/declare", "require", "com.ibm.team.dashboard.web.ui.Viewlet", "dojo/dom-attr", "dojo/date", "dojo/topic", "dojo/on" ], function (declare, Viewlet, domAttr, Date, topic, on){ return declare("my.Widget", dojo.global.com.ibm.team.dashboard.web.ui.Viewlet, { DEFAULTHEIGHT: 3, SUPPORTEDBROWSER: null, |
Any reason you want to use AMD, as Dojo 2.0 has not been released yet? As far as I can tell, the latest CLM 5.0.2 still uses Dojo 1.8.4. And for this version, you need to load Dojo with "async:true" to use AMD. But I don't see CLM load Dojo this way, and am not sure how you can change the way it loads Dojo.
Comments
Jonas Studer
commented Jan 14 '15, 5:58 a.m.
Hy Donald,
I was referring to this article.
Jonas Studer
commented Jan 15 '15, 4:15 a.m.
Ok, thanks for calrification.
Jonas Studer
commented Jan 15 '15, 4:16 a.m.
Ok, thanks for calrification.
|
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.