cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco.module.* is not a constructor [SOLVED]

redraccoon
Star Contributor
Star Contributor
Hello my question is really simple

I want to open a module "document-picker" when i click on my custom button in my documentLibrary in the "toolbar.js"

so, like I saw in a lot of example

<javascript> var instance = new Alfresco.module.DocumentPicker(this.id + "-linkDocumentPicker", Alfresco.ObjectRenderer); </javascript>

but I always get the error "alfresco.module.DocumentPicker is not a constructor" in the log of my browser


but as you can see this is the right constructor … by the way none of my module work by this technique (only the upload button but he is working with a fileUploadGetInstance, he is different)


<javascript>   Alfresco.module.DocumentPicker = function(htmlId, objectRendererClass)
   {
      Alfresco.module.DocumentPicker.superclass.constructor.call(this, "Alfresco.module.DocumentPicker", htmlId, ["button", "menu", "container", "resize", "datatable", "datasource"]);

      /**
       * Decoupled event listeners
       */
      this.eventGroup = htmlId;
      YAHOO.Bubbling.on("renderCurrentValue", this.onRenderCurrentValue, this);
      YAHOO.Bubbling.on("selectedItemAdded", this.onSelectedItemAdded, this);
      YAHOO.Bubbling.on("selectedItemRemoved", this.onSelectedItemRemoved, this);
      YAHOO.Bubbling.on("parentChanged", this.onParentChanged, this);
      YAHOO.Bubbling.on("parentDetails", this.onParentDetails, this);

      // Initialise prototype properties
      this.pickerId = htmlId + "-cntrl-picker";
      this.widgets = {};
      this.columns = [];
      this.currentValueMeta = [];
      this.selectedItems = [];

      //use specifed object renderer or default to default object renderer
      var objectRendererClass =  objectRendererClass || Alfresco.ObjectRenderer;
      this.options.objectRenderer = new objectRendererClass(this);

      return this;
   }; </javascript>

the picker is in my modules
1 REPLY 1

redraccoon
Star Contributor
Star Contributor
Ok I finaly found

As you can see in the toolbar.js there is the upload button wich work perfectly, so I mooved out the docLibAction.js from the module to have the same error but I got 2 errors :

<blockquote> Alfresco.module.docLibAction is not a constructor (ok)</blockquote>

but also

<blockquote> can't find docLibAction.js</blockquote> , so I cliked on the error to see that the module.js is called in the webpage … my problem was <strong>I tried to use my module without calling him in my webpage</strong>

So I looked for the declaration and you have to add (for this example) the js in the documentlist-v2.get.html.ftl

<javascript><@markup id="css" >
<@link rel="stylesheet" type="text/css" href="${url.context}/res/modules/document-picker/document-picker.css" group="documentlibrary"/>
<@viewRenderererCssDeps/>
</@>

<@markup id="js">
<@script type="text/javascript" src="${url.context}/res/modules/document-picker/document-picker.js" group="documentlibrary"/>
   <@viewRenderererJsDeps/>
</@></javascript>

and now you can call the constructor !!!