AnsweredAssumed Answered

Basic dashlet setup error (superclass undefined)

Question asked by cybertoast on Nov 19, 2009
Latest reply on Nov 19, 2009 by mikeh
I've got a situation I don't understand with dashlets. I've created dashlets that work, and now I have new dashlets that don't and can't figure out why some don't work.

I'm creating a custom My Sites dashlet, and putting it into web-extension/site-webscripts/com/myco/components/dashlets/myco-sites.get.*. I've also got client-side handlers in tomcat/webapps/share/components/dashlets/myco-sites.js (and -min.js).

When I refresh the scripts and load my client-side javascript I get:

MycoSites.superclass is undefined
at the MycoSites.supeclass.constructor.call() - detailed below.

My myco-sites.get.desc.ftl is:

<webscript>
   <shortname>MyCo Document Sites</shortname>
   <description>MyCo document sites with popup</description>
   <authentication>user</authentication>
   <family>user-dashlet</family>
   <url>/components/dashlets/myco-sites</url>
</webscript>

This binds the dashlet to /components/dashlets/myco-sites, but there's no physical file at any /components/dashlets/myco-sites location, if my understanding is correct. It's just an internal path to the script.

My client code (and associated YUI components) is included in the myco-sites.get.head.ftl:

<@script type="text/javascript" src="${page.url.context}/yui/yahoo-dom-event/yahoo-dom-event.js"></@script>
<@script type="text/javascript" src="${page.url.context}/yui/button/button.js"></@script>
<@script type="text/javascript" src="${page.url.context}/yui/container/container.js"></@script>
<@script type="text/javascript" src="${page.url.context}/components/dashlets/myco-sites.js"></@script>

My myco-sites.get.html.ftl is basically the same as my-sites.get.html.ftl, except that I instantiate MycoSites instead of MySites:

<script type="text/javascript">//<![CDATA[
   new MycoSites("${args.htmlid}").setOptions({
   }).setMessages(${messages});
   new Alfresco.widget.DashletResizer("${args.htmlid}", "${instance.object.id}");
//]]></script>

My $tomcat/webapps/share/components/dashlets/myco-sites.js is:

(function()
{
   /**
    * YUI Library aliases
    */
   var Dom = YAHOO.util.Dom,
      Event = YAHOO.util.Event;

   /**
    * Alfresco Share aliases
    */
   var $html = Alfresco.util.encodeHTML;

   /**
    * Alfresco.SampleComponent constructor.
    * @return {Alfresco.SampleComponent} the new component instance
    * @constructor
    */
   MycoSites = function MycoSites_constructor(htmlId)
   {
      MycoSites.superclass.constructor.call(this, "MycoSites", htmlId, ["button", "container"]);
      this.preferencesService = new Alfresco.service.Preferences();
      return this;
   };
   YAHOO.extend(MycoSites, Alfresco.component.base,
   {}
   );

I've got other dashlets that work just fine, and now copying them to a new set of files and reloading them causes the same "superclass is undefined" error.

I can't recall having to register the dashlets in any special way. I've also tried to name my client-side function as Alfresco.dashlet.MycoSites (instead of just MycoSites), and still the same problem.

I'd greatly appreciate any pointers - this is driving me slightly batty since I can't see that I've done anything wrong!

Thanks much for any help.

Outcomes