Web Scripts and Behaviours

cancel
Showing results for 
Search instead for 
Did you mean: 
Active Member

Web Scripts and Behaviours

I created a behaviour that display a message in the console once a file is created.
I created a model following this tutorial Working With Custom Content Types in Alfresco | ECMArchitect | Alfresco Developer Tutorials . (descriptionand date attributes)

How can I save that message to that model. Than use webscripts to display in Json or html format ?

9 Replies
Established Member II

Re: Web Scripts and Behaviours

Hello,

To give you a more accurated answer It would be very usefull if you attached your custom model definition to the question.

Anyway from your behaviour implementation you have to use NodeService to specialize the type of the node created or add an aspect to it, depending how you have definited your model, and then set the property with your message.

NodeService | Alfresco Documentation 

In this other link you can find the information you will need to develope a custom web script:

Web Script tutorials | Alfresco Documentation 

Basicaly you need a web service that received the noderef of your content, load it and show the messagge property in the format you want.

Active Member

Re: Web Scripts and Behaviours

is it possible to create a behavior inside a webscript ?

Established Member II

Re: Web Scripts and Behaviours

I don't understand exactly what are your requirements. 

Behaviors are pieces of logic that will be executed in response to an event in the respository and a web script is a REST service, are totally diferent things.

If you want to execute a piece java code when you call a web script you must see th Java Backed web scripts

Java-backed web scripts | Alfresco Documentation 

Creating a Folder Listing Java-backed web script | Alfresco Documentation 

On the other hand if what you want is execute the same code in a behavior and when you call the web script without duplicating code your best option is create a respository action and invoke it from both sides:

Adding new actions to the Document Library | Alfresco Documentation 

Active Member

Re: Web Scripts and Behaviours

What I want to do is, when someone create a file, I want to display in the share a message "Username added a file with a filename" and save this event to a  database in a table created by me.

Established Member II

Re: Web Scripts and Behaviours

Saving the event in your own database table is clearly a task that you could do in a behaviour.

When you say "display in share a message", do you mean show a realtime message to other users loged in share"?

Take into account that share already display this kind of information in the activity dashlets from the user and site dashboard. It's not real time but are to update everytime you reach the dashboard.

Active Member

Re: Web Scripts and Behaviours

Yes that's exactly what i want to do, I just want to display the message my way.

Established Member II

Re: Web Scripts and Behaviours

In that case in the following links  you can find all the information you need to create a new dashlet:

Surf Dashlets | Alfresco Documentation 

Aikau dashlets | Alfresco Documentation 

The recomended way to create a new dashlet its using Aikau framework but how you want to adapt an existent dashlet maybe it will be easiest use Surf framework.

If instead of create a new dashlet you decide to modifing activity one you can consult this

Modifying Out-of-the-box Surf dashlets | Alfresco Documentation 

Surf Extension Modules | Alfresco Documentation 

Always is a good idea to study in Alfresco Source Code to use it like a guide in your developments, but in this case is much more recomendable.

Established Member II

Re: Web Scripts and Behaviours

For the real-time approach I remember that some time ago i saw a real time activity monitor but i didn't test it. You could take a look:

GitHub - juliomaqueda/alfresco-activity-monitor 

Active Member

Re: Web Scripts and Behaviours

Thanks Roberto.