Embed
Email

Alfresco Web Scripts

Document Sample
Alfresco Web Scripts
Alfresco Web Scripts

Scriptable MVC for REST, AJAX,

Widgets and Portlets

What are Web Scripts?



Web Scripting Consumer / Client

!Agile Script-Driven MVC

!Multiple uses

! Roll your own API

! Create new UI components

! Create portlets/widgets

! Expose WCM/AVM features

!Script-based implementation

! Server-side JavaScript

! Freemarker

!Limited only by your imagination

! Integration: Create a mashup

! Search: Exposed to other systems.

Freemarker (View)

! Rich Internet Applications

! Cross-language

! Cross-platform

JavaScript (Controller)



Alfresco Repository (Model)

Two types of Web Scripts…



• Data Web Script

– RESTstyle / RESTful URL

– Returns structured data:

• XML

• JSON

• CSV

• UI Web Script

– Renders self-contained UI.

– Can leverage Data Web Scripts.

Examples



Web Scripting

Examples

!JavaScript that generates

JSON output.



!AJAX & DHTML Portlet



!E.g. OpenSearch is hosted

as Web Script

Lightweight Portlet Model

• Single Portlet Approach

– One portlet can render many scripts.



• Service-oriented interfaces

– Transformation

– Templating

– Workflow

• JavaScript extensions

– Access to full Alfresco data model.

• Templating

– FreeMarker for mark-up.

– Access to compound structures.

• REST-style of interface

– URL-addressability of all functions.

Richer, Mashable User Experience

Content authored

and categorized Content metadata

drives mashup









RSS content feeds for both

Web Content and Documents from

same Alfresco repository

Developing Web Scripts



• Where do they live?

– Under “Data Dictionary”

– In Classpath Under

“**/alfresco/extension/templates/webscripts”

• What are the required components?

– Descriptor

– JavaScript

– FreeMarker Template

• How do I (re)deploy them?

– They’re auto-deployed and auto-refreshed

Sample Descriptor





Sample Alfresco Repository

Services

Repository services and

utilities

/repo/

/repo/node/{nodeid}

/repo/node/path/{path}



guest



reposervices.get.js (part 1)







var curNode = companyhome;



// Check for presence of arguments and locate the referenced node or path.

if (url.extension != "") {

if (url.match == "/alfresco/service/repo/node/path/") {

var expr = "Company Home/";

var str = url.extension.replace(expr,"");

// If the path was just "Company Home/" then don"t bother setting curNode

to anything.

if (str != "") {

curNode = companyhome.childByNamePath(str);

}

} else if (url.match == "/alfresco/service/repo/node/") {

curNode = search.findNode("workspace://SpacesStore/" + url.extension);



}

} // end if

reposervices.get.js (part 2)

// Initialize the variables and arrays

var children = curNode.children;

var results = {};



var numDocs = 0;

var numSpaces = 0;



results.node = curNode;

results.spaces = new Array();

results.documents = new Array();



// Iterate through children and populate return

objects

for (var i=0; i











Spaces:



${space.name}





Documents:



${doc.name}









How does this apply to portlets?



• Portlets can leverage Web Scripts as a

“Data API”.

• Portlets can incorporate UI Web Scripts

as “Widgets”.

JSR 168 Portlet

• Standard JSR 168 portlet invokes Portal

a Web Script via HTTP.

JSR

• Web Script returns JSON text.

– Parsers for Java at JSON.org

168









JSON

over

HTTP



Freemarker (View)



JavaScript (Controller)



Alfresco Repository (Model)

Alfresco Portlet

• Single portlet can render any

UI Web Script.

• Currently requires Alfresco to

be deployed on the same

application server.

• IFRAME portlet can be a

viable alternative for remote

Alfresco servers.

Demo







• Examine the Services Registry

• Invoke our Service

• Use JavaScript Debugger

• Tour other Web Scripts & Portlets

The End



• For more information, visit:

– http://wiki.alfresco.com/wiki/Web_Scripts

– http://wiki.alfresco.com/wiki/JavaScript_API

– http://wiki.alfresco.com/wiki/Template_Guide

• Contact Info:

– Luis Sala, Sr. Director of Solutions Engineering

• luis.sala@alfresco.com

• http://blogs.alfresco.com/luissala

Alfresco Web Scripts

Scriptable MVC for REST, AJAX,

Widgets and Portlets


Related docs
Other docs by BrandalJaclson
LICIO GELLI
Views: 61  |  Downloads: 0
DRILLS
Views: 12  |  Downloads: 0
Traditional Japanese color
Views: 266  |  Downloads: 0
Patterns of Three by
Views: 11  |  Downloads: 0
CHISME
Views: 2  |  Downloads: 0
Free Summer Jazz Concert Schedule
Views: 16  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!