04-07-2021 06:26 AM
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.
04-07-2021 09:44 AM
04-08-2021 05:41 AM
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 ->
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 ->
I draw your attention that this component is not on this page (Alfresco.DNDUpload) ->
And on this page everything is fine (there are no above errors) ->
P.S. sorry for my bad english.
Explore our Alfresco products with the links below. Use labels to filter content by product module.