cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco Error alfresco.fileupload is not a constructor.

doroga7
Champ in-the-making
Champ in-the-making

Hey! I am a beginner Alfresco programmer. I have a problem with Alfresco.FileUpload (). On one page this method works, but on the other it gives the error alfresco.fileupload is not a constructor. Tried connecting to components / upload / file-upload.js page but it was unsuccessful.

2 REPLIES 2

cristinamr
World-Class Innovator
World-Class Innovator

Hi! We need more technical details: could you please share with us your code? In adittion it could help to have the log error paste it here.

With these details we can figure out what is happening.

Cheers,

Cris.

--
VenziaIT: helping companies since 2005! Our ECM products: AQuA & Seidoc

doroga7
Champ in-the-making
Champ in-the-making

Hi, Cris!

To fix the error, I initialized the javascript directly on the pagen the page -> 

<alfresco-config>
   <config>
        <forms>
            <dependencies>
                <js src="/components/upload/file-upload.js"/>
            </dependencies>
        </forms>
    </config>
</alfresco-config>

This helped fix the error, but another appeared -> "No instance of uploader type 'Alfresco.DNDUpload' exists."

I as before initialized js on the page ->

<alfresco-config>
    <config>
        <forms>
            <dependencies>
                <js src="/components/upload/dnd-upload.js"/>
                <js src="/components/upload/file-upload.js"/>
            </dependencies>
        </forms>
    </config>
</alfresco-config>

Didn't help this time.

Delving into error ->

image

The "ComponentManager" is initialized here. This is where the component we need is pushed. ->

Alfresco.util.ComponentManager = function()
{
   var components = [];
   return (
   {
      register: function CM_register(p_oComponent)
      {
         if (p_oComponent.id !== "null" && components.hasOwnProperty(p_oComponent.id))
         {
            var purge = components[p_oComponent.id];
            if (purge.name === p_oComponent.name)
            {
               if (typeof purge.destroy  === "function")
               {
                  purge.destroy();
               }
               this.unregister(components[p_oComponent.id]);
            }
         }
         components.push(p_oComponent);
         components[p_oComponent.id] = p_oComponent;
      },
      unregister: function CM_unregister(p_oComponent)
      {
         for (var i = 0; i < components.length; i++) // Do not optimize
         {
            if (components[i] == p_oComponent)
            {
               components.splice(i, 1);
               delete components[p_oComponent.id];
               break;
            }
         }
      },

      reregister: function CM_reregister(p_oComponent)
      {
         this.unregister(p_oComponent);
         this.register(p_oComponent);
      },

      find: function CM_find(p_oParams)
      {
         var found = [];
         var bMatch, component;

         for (var i = 0, j = components.length; i < j; i++)
         {
            component = components[i];
            bMatch = true;
            for (var key in p_oParams)
            {
               if (p_oParams[key] != component[key])
               {
                  bMatch = false;
               }
            }
            if (bMatch)
            {
               found.push(component);
            }
         }
         return found;
      },

      findFirst: function CM_findFirst(p_sName)
      {
         var found = Alfresco.util.ComponentManager.find(
               {
                  name: p_sName
               });

         return (typeof found[0] == "object" ? found[0] : null);
      },

      get: function CM_get(p_sId)
      {
         return (components[p_sId] || null);
      },

      list: function CM_list()
      {
         return components;
      }
   });
...
... }();

But when loading this page, the component we need is not there ->

imageimage

I draw your attention that this component is not on this page (Alfresco.DNDUpload) ->

image

And on this page everything is fine (there are no above errors) ->

image

P.S. sorry for my bad english.