cancel
Showing results for 
Search instead for 
Did you mean: 

Upload form in dashlet

spazur
Champ in-the-making
Champ in-the-making
Total newbie here, from a VB background, so sorry in advance for what may be simple questions.  I have an upload form/webscript working on the Explorer side of things, and want to drop that url into a dashlet for one of our Share sites.  I am setting a destination folder for all uploaded files to go to, and in Explorer, this webscript works perfectly.

But, when I try to point to this in a Webview dashlet, it makes the user log in to Explorer, even if they are already logged in to Share.  I'm finding I can't just move the script to Share because some of the methods I am using are not available.  I have tried several things that I have found on the forums to no avail, and am hoping my ignorance is the main reason and not limitations of Alfresco. 

I am using the file upload code found on the examples wiki page (http://wiki.alfresco.com/wiki/Web_Scripts_Examples#File_Upload), with the only significant change being instead of companyHome as a destination, I use:

var space_to_use = companyhome.childByNamePath("Sites/xxxxx/documentLibrary/xxxxxxx/Idea Repository");
upload = space_to_use.createFile("upload" + space_to_use.children.length + "_" + filename) ;

Can anyone offer any advice?  Code would be real helpful!  Thank you very much for your help.

SP
4 REPLIES 4

wabson
Star Contributor
Star Contributor
Hi SP,

The best example that I'm aware of of a custom file upload function is on the 'Edit profile' page.

In order to implement something similar in a dashlet you will need to use some client-side JavaScript. Start by taking a look at the Alfresco.UserProfile class, which implements the view/edit profile page, and is defined in components/profile/profile.js inside the Share webapp. You could use this class as a template for your own, but you might find it easier to walk through the code in the Sample Dashlet project in Share Extras.

The user profile upload script also uses a custom web script on the repository side to receive the files, but you shouldn't need to do this unless you have specific requirements. See https://forums.alfresco.com/en/viewtopic.php?f=48&t=36266, which shows how to use a file upload instance in a more generic way without any custom web scripts beyond your dashlet itself.

Cheers,
Will

spazur
Champ in-the-making
Champ in-the-making
That sounds like overkill, since I already have a functioning form/script in Explorer.  Are you telling me there is no way for Share (where I am already logged on) to communicate with an Explorer script without making me log in again?  That would solve my problem.

wabson
Star Contributor
Star Contributor
If your existing solution uses web scripts, then you can re-use those, since they are implemented in both Explorer and in Share. But otherwise you cannot, since Explorer is a completely different UI from Share, built on a JSF framework. Share was deliberately built from the ground up on the much newer Spring Surf/Web Scripts frameworks, precisely to avoid the limitations of the Explorer UI and JSF.

The downside is that UI customizations aren't directly portable between the two, but if you use web scripts as the basis for any future prototyping you should find them much easier to build into a complete Share customisation, and Share itself offers vastly more options for extending and customising the UI.

Cheers,
Will

peter88
Champ in-the-making
Champ in-the-making
good moorning
i m not good in english but i want to explain my problem
I have the same problem !
my upload file web script customized work perfectly in alfresco expolrer
but i want to execute him in alfresco share

il have copied my files in
C:\Alfresco\tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\dashlets
and i add same modifications like  this in upload.get.desc.xml
<webscript>
  <shortname>Upload  File </shortname>
  <description>Form for uploading file</description>
   <!– one of dashlet, site-dashlet or user-dashlet –>
   <family>dashlet</family>
  <url>/mycompany/components/dashlets/upload</url>
  <authentication>user</authentication>
</webscript>

and this in upload.post.js
function main()
{
var filename = null;
var content = null;
……..
…….
  // create document in folder for uploaded file
  var folder = search.findNode(ser);
  upload = folder.createFile("upload" + folder.children.length + "_" + filename) ;
……….
………..;
}

main();

but this do not work


the error is
[code]An error has occured in the Share component: /share/page/mycompany/components/dashlets/upload.
It responded with a status of 500 - Internal Error.
Error Code Information: 500 - An error inside the HTTP server which prevented it from fulfilling the request.
Error Message: 04230005 Failed to execute script 'classpath*:alfresco/site-webscripts/org/alfresco/components/dashlets/upload.post.js': 04230004 ReferenceError: "search" n'est pas défini (file:/C:/Alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/dashlets/upload.post.js#105)
Server: Alfresco Spring WebScripts - v1.0.0 (Release 958) schema 1 000
Time: 23 mai 2012 10:47:21
Click here to view full technical information on the error.