cancel
Showing results for 
Search instead for 
Did you mean: 

Share/Surf WebScript with Java backed bean

bela
Champ in-the-making
Champ in-the-making
Hey,

I am trying to write a web script into alfresco share, and I want it to have a Java backed bean. The purpose of the webscript is to move users from one user group to another. I have already written a web script with this functionality into alfresco itself, but I want it to be in a share application also, completely independent. My problem is that I didn't find any usable documentation regarding java backed share/surf web script development. Any help would be appreciated.
10 REPLIES 10

mikeh
Star Contributor
Star Contributor
The preferred way would be to expose your Alfresco (repository) version as a RESTful service and call it from Share that way.

Any reason why you wouldn't want to try that approach? That's how Share has been implemented.

Thanks,
Mike

bela
Champ in-the-making
Champ in-the-making
Thanks for the quick reply.

If I understand you correctly, you mean to put the entire webscript in alfresco and render a JSON response, which I digest in another Share webscript using a javascript controller, right? If this is what you mean, I would appreciate a hint where to look for an example. I read a lot of posts about looking at the share source code, but I haven't found an example that does just that.

Thanks again for the help.

mikeh
Star Contributor
Star Contributor
Yes, that's exactly it. You can pretty much look at any example in Share - the Document Library is all AJAX/JSON-based although with JavaScript-based repository web scripts rather than Java-backed; but that's just an implementation detail.

Thanks,
Mike

andrewriver
Champ in-the-making
Champ in-the-making
Hi,

There is already any way to make a Java webscript in the new version of alfresco share (3.4.c) ? If so, where can I get an example?

Thanks.

mikeh
Star Contributor
Star Contributor
Yes, both the Forms UI component and the I18N Messages webscripts are Java-backed.

Thanks,
Mike

andrewriver
Champ in-the-making
Champ in-the-making
Thanks MikeH! It works!

I saw the webscripts defined in slingshot-application-context.xml and registered here my custom java webscript…I'll be working on it and if I would have any question I'll let you know.

sans
Champ in-the-making
Champ in-the-making
Hi andrewriver,
Can you please explain me what steps did you take and what files you created and where did you put all these files?
I am trying to create a Subscribe action in share documentlibrary. I have created it successfully and deployed on tomcat.
when a user clicks on the subscribe link/action under +More.. it displays the message document/folder subscribed successfully.
But this all I implemented using javascript based webscripts at share. Now I want to convert this into java backed webscript.
Can you please help me in this? Because I am not sure where shall I place my java file and how should I connect/link this file to my
subscribe.post.desc.xml, subscribe.post.json.ftl and subscribe.post.json.js.
All these files are stored/placed in templates\webscripts\org\alfresco\slingshot\documentlibrary\action folder.
And a javascript file which gets triggered when user clicks on the link is stored in \share\components\documentlibrary folder.
Snippet from subscribe-action-min.js
webscript:
         {
            name: "subscribe/site/{site}/{container}",
            //name: "demo/simple",
            method: Alfresco.util.Ajax.POST
         }
Which in turn call subscribe.post.json.js and subscribe.post.json.ftl.

Thanks for your help

Sanjay.

andrewriver
Champ in-the-making
Champ in-the-making
Hi sans

You must create your java webscript (Abtract or Declarative). Then, create the descriptor *.desc.xml and ftl or js that you need. After that, register your new webscript in the file slingshot-application-context.xml setting the java class of your webscript.

That's it. You can check your new webscript at the Webscripts Home of your application (localhost/share/service/index)


Hope it works. Good luck with that.

sans
Champ in-the-making
Champ in-the-making
Hi andrewriver,
thanks for the reply.
Well I did same thing. The only difference was the file where i defined the bean.
I defined it in web-scripts-application-context.xml under tomcat\shared\classes\alfresco\extension.
It was registered under localhost/alfresco/service/index.

It worked!!!!

Thanks a lot!!