SlideShare a Scribd company logo
Spring Surf & Web Scripts!
Dave Draper – UI Engineer - @_DaveDraper!
History lesson...
2007
  • Alfresco 2.0 introduces first REST API (early WebScripts concepts)!
  • Alfresco 2.1 introduces WebScripts!
     • REST framework, JSR-311 (Jax-RS) URI Index!
     • Scriptable controllers (or backed by Spring Java Beans)!
     • FreeMarker template output (or Java output stream)!
2008
  • Alfresco Web Framework demo-ware (model objects, JSP, FTL)!
  • Alfresco Page Render (WebScripts as components on a page)!
  • Combined, productised and renamed to Surf!
  • Alfresco Share 3.0, 3.1 – Alfresco collaboration and DM – modern
   XHTML and Ajax based interface!
History lesson (cont)...
Early 2009
  • Alfresco Share 3.2!
  • First contact between Alfresco and Spring Source!
Late 2009
  • Alfresco Surf and WebScripts integrated with Spring MVC!
  • Alfresco Surf and WebScripts contributed as Spring Extension –
   Spring WebScripts and Spring Surf!
  • Alfresco Share 3.3 – refactored onto Spring WebScripts and Spring
   Surf!!
2010
  • 3 Milestones and RC1 release!
  • Alfresco Share 3.4 – using SpringSurf RC1!
History lesson (cont)...
2011
 • Alfresco Team!
 • New extensibility capabilities added!
 • Version 1.0.0 releases!
 • Alfresco Share 4.0!
What Are WebScripts?
• Services bound to a URIs which respond to
 HTTP methods such as GET, POST, PUT and
 DELETE!
• Support multiple formats (HTML, JSON & XML)!
• A framework for creating a REST API!
• Made up of descriptor, controller, properties,
 configuration and presentation files!
WebScripts!
• Descriptor (XML)
• Controller (JavaScript/Java Spring Bean)
• Response Formats (FreeMarker)
• I18N properties (Text)
• Configuration (XML)
Response Formats!
•  Available formats
 • HTML!
 • Text!
 • XML!
 • ATOM!
 • RSS!
 • JSON!
•  Set default in Descriptor (if more than one available)
•  Request by:
 • Extension (e.g. /script1.html, /script1.json, etc)!
 • Format request parameter (e.g. /script1?format=xml)!
Why Use Web Scripts?
•    Rapid development (no server restarts)
•    Separation of concerns (MVC)
•    Localization
•    Extensibility
•    FreeMarker and JavaScript
But What Is Spring Surf ?
•  An extension to Spring MVC
•  A set of controllers, resolvers and views
•  A way of breaking an HTML page into re-
   usable composite parts
•  An interface to the Alfresco Repository
•  The framework that underpins Alfresco
   Share
Example Spring Surf Objects
•    Pages
•    Template Instances
•    Regions
•    Chrome
•    Components
•    Sub-Components
Sub-­‐
  Component	
  
   Component	
  
     Region	
  
 Region-­‐Chrome	
  
  Components	
  
    Chrome	
  


Template-­‐Instance	
  
      Page	
  
Mistakes were made…
•    Chrome
•    Scopes
•    No Component nesting
•    1-1 Region/Component binding
•    Spring Roo
•    Tools
•    Difficult to match output to source
…but there is lots of good stuff !
•     Themes
•     Model Object stores (file system, classpath, remote,
      etc)
•     Presets / object creation
•     URI templates
•     Remote connections
•     Authentication
•     Extensibility
•     Endlessly configurable
What can you do with it?
• Rapid web-tier view composition – Spring MVC
 View Resolver!
• FreeMarker, JSP, Groovy, PHP pages!
• WebScript, FTL, JSP, Groovy, PHP components!
• Simple JavaScript, Groovy controllers!
• Remote API – REST request/response
 processing!
• WebScripts – standalone REST API tier!
• Portlets!
What you SHOULD do with it?!

 • Customize Alfresco Share!
 • Use WebScripts and FreeMarker!
 • Use JavaScript controllers!
 • Use Endpoints to contact an Alfresco Repository
  in standalone applications!
SOME USEFUL INFORMATION!
WebScript and Surf Object lookup!
Authentication (WebScripts & Surf Pages)!

•  Use <authentication> element
•  Available types:
 • “none”!
 • “guest”!
 • “user”!
 • “admin”!
•  Authenticates against Alfresco Repository
•  Can use “runas” property with WebScripts only
URI Templates (WebScripts)!

•  Use tokens in URL
 • e.g. “/x/{token1}/y/{token2}/z”!
•  Can define multiple URLs in single descriptor
•  Use “url.templateArgs” to access
 • ${url.templateArgs.token1}!
URI Templates (Surf Pages)!

•  Define “uri-template” in <alfresco-config> (e.g. “share-config-
   custom.xml)
  • Include {pageid} token for Page mapping!
  • Or ensure Page exists (e.g. Created through Preset)!
•  Use page.url.templateArgs to access tokens
  • e.g. ${page.url.templateArgs.token1}!
Surf Configuration!

•  Configuration object
   • Site home page!
   • Site theme!
•  Surf.xml
   • Object type implementations (e.g. AdvancedComponent)!
   • User factories!
   • Site configuration!
   • Chrome!
   • Page type (e.g. Login)!
   • Module Deployment!
•  Spring Application Context
   • Services (configuration loading, user factories, persistence, remote access, etc)!
   • Controllers (login controllers, etc)!
   • Interceptors!
Custom Home Page!

•  From:
   http://blogs.alfresco.com/wp/ddraper/2011/11/01/advanced-
   share-customization-part-1/
•  Optionally override <site-configuration> in “surf.xml”
  • Default is “slingshot.site.configuration”!
•  Set <root-page> property in Configuration object
Custom Login Page!
•  From:
   http://blogs.alfresco.com/wp/ddraper/2011/11/03/advanced-
   share-customization-part-2/
•  Create Page and Template-Instance objects for custom
   login page
•  Define new default “login” Page-Type object
Regions and Components
•         Regions define location into which Components can
          be bound
•         Binding done through region-id, source-id and
          scope
     o      Forced 1-1 bindings
     o      Flawed concept for Component switching
•         Sub-Components introduced as a workaround
•         Components SHOULD use ComponentType or
          Processor but are “optimized” to use WebScript
          URL
Remote API
• Connectors & Authenticators!
• XML configure access to “endpoints” – obtained
 by id!
• Access HTTP methods through JavaScript
 controller or Ajax via proxy controller!
• Endpoints hide the URL stem from scripts –
 authentication encapsulated by connectors and
 authenticators!
• Connect to multiple REST sources; alfresco,
 wiki, search!
Remote API – Example!
var conn = remote.connect("alfresco");
var json = conn.get("/api/products/" + args.filter);
if (json.status == 200)
{
   // Create JavaScript objects from the response
   var obj = eval('(' + json + ')');
   if (obj)
   {
      // Perform processing on the js objects
      // set results into the model for the template
      model.results = somearray;
   }
}
Model Object Stores
• Persisters – read model object definitions from
 classpath, WEB-INF, JARs!
• Alfresco legacy locations and Spring “friendly”
 locations!
  o Migration of Alfresco Surf 3.2 apps!
  o New locations require less files, folders!
• Read and write to remote location and local file
 system!
• Example - Alfresco Share stores pages and
 components for dynamic dashboards in the
 repository!
Component .head.ftl template!

•      Allow WebScripts to add JavaScript and CSS dependencies into
       HTML <head>
•      Use ${head} in Template Instance to output dependencies into
       <head>
•      Use <@script> to automatically switch between .js and –min.js



     <link rel="stylesheet" type="text/css" href="${page.url.context}/
       products/products.css" />
     <script src="${page.url.context}/products/products.js"></script>
Useful Runtime Tools
•  /service/index
 o    Browse WebScripts

 o    WebScript refresh

 o    SurfBug toggle
Roadmap!

•  Forking from Spring back into Alfresco
•  Continued development (more extensibility
   features, performance improvements)
•  Continued use in Alfresco projects
•  More blogging, forums and documentation
How do I use it?!

 • You CAN SVN checkout, maven build:
  https://src.springframework.org/svn/se-surf/trunk!
 • You SHOULD use Alfresco Community JARs
  when available!
Learn More!

•  Blog posts:
 • http://blogs.alfresco.com/wp/ewinlof/!
 • http://blogs.alfresco.com/wp/kevinr/!
 • http://blogs.alfresco.com/wp/ddraper/!
 • http://mindthegab.com/!
•  Alfresco Forum: “Surf Development”
Questions?!
PLAT-7 Spring Web Scripts and Spring Surf

More Related Content

What's hot (19)

PPTX
RESTful Services
Jason Gerard
 
PDF
WCM-7 Surfing with CMIS
Alfresco Software
 
PDF
An Intense Overview of the React Ecosystem
Rami Sayar
 
PPT
Node and Azure
Jason Gerard
 
PPTX
Introduction to Monsoon PHP framework
Krishna Srikanth Manda
 
PDF
RESTful Rails2
Wen-Tien Chang
 
PDF
CUST-10 Customizing the Upload File(s) dialog in Alfresco Share
Alfresco Software
 
PDF
An Introduction to the Laravel Framework (AFUP Forum PHP 2014)
daylerees
 
PPTX
Agile sites2
Michele Sciabarrà
 
PPTX
Agile sites @ telmore
Michele Sciabarrà
 
PDF
Building a spa_in_30min
Michael Hackstein
 
PDF
Oracle APEX Nitro
Marko Gorički
 
PPTX
Oak, the architecture of Apache Jackrabbit 3
Jukka Zitting
 
PPTX
SilverStripe From a Developer's Perspective
ajshort
 
KEY
LatJUG. JSF2.0 - The JavaEE6 Standard
denis Udod
 
PDF
A Day of REST
Scott Taylor
 
PDF
Webcomponents are your frameworks best friend
Filip Bruun Bech-Larsen
 
PPTX
Laravel Meetup
Whisnu Sucitanuary
 
PPTX
Web Application Frameworks (WAF)
Ako Kaman
 
RESTful Services
Jason Gerard
 
WCM-7 Surfing with CMIS
Alfresco Software
 
An Intense Overview of the React Ecosystem
Rami Sayar
 
Node and Azure
Jason Gerard
 
Introduction to Monsoon PHP framework
Krishna Srikanth Manda
 
RESTful Rails2
Wen-Tien Chang
 
CUST-10 Customizing the Upload File(s) dialog in Alfresco Share
Alfresco Software
 
An Introduction to the Laravel Framework (AFUP Forum PHP 2014)
daylerees
 
Agile sites2
Michele Sciabarrà
 
Agile sites @ telmore
Michele Sciabarrà
 
Building a spa_in_30min
Michael Hackstein
 
Oracle APEX Nitro
Marko Gorički
 
Oak, the architecture of Apache Jackrabbit 3
Jukka Zitting
 
SilverStripe From a Developer's Perspective
ajshort
 
LatJUG. JSF2.0 - The JavaEE6 Standard
denis Udod
 
A Day of REST
Scott Taylor
 
Webcomponents are your frameworks best friend
Filip Bruun Bech-Larsen
 
Laravel Meetup
Whisnu Sucitanuary
 
Web Application Frameworks (WAF)
Ako Kaman
 

Similar to PLAT-7 Spring Web Scripts and Spring Surf (20)

PDF
Developer’s intro to the alfresco platform
Alfresco Software
 
PDF
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
J V
 
PDF
BP-9 Share Customization Best Practices
Alfresco Software
 
PDF
BP-7 Share Customization Best Practices
Alfresco Software
 
PDF
Rapid API Development ArangoDB Foxx
Michael Hackstein
 
PPTX
Alfresco overview EDM
sang nguyen
 
PDF
Spring 3 - An Introduction
Thorsten Kamann
 
PPTX
Share point development 101
Becky Bertram
 
PDF
Advanced guide to develop ajax applications using dojo
Fu Cheng
 
PDF
Introduction to Flask Micro Framework
Mohammad Reza Kamalifard
 
PDF
Building APIs in an easy way using API Platform
Antonio Peric-Mazar
 
PDF
Laravel 4 presentation
Abu Saleh Muhammad Shaon
 
PDF
PLAT-16 Using Enterprise Content in Grails
Alfresco Software
 
PDF
Play Framework and Activator
Kevin Webber
 
PDF
Alfresco Coding mit dem Alfresco SDK (auf Englisch) - Julien Bruinaud, Techni...
Nicole Szigeti
 
PPTX
Integrating Alfresco with Portals
Piergiorgio Lucidi
 
PPTX
WebNetConf 2012 - Single Page Apps
Pop Apps
 
PDF
Web Technologies in Java EE 7
Lukáš Fryč
 
PDF
CUST-2 New Client Configuration & Extension Points in Share
Alfresco Software
 
PPTX
Progressive Web Apps and React
Mike Melusky
 
Developer’s intro to the alfresco platform
Alfresco Software
 
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
J V
 
BP-9 Share Customization Best Practices
Alfresco Software
 
BP-7 Share Customization Best Practices
Alfresco Software
 
Rapid API Development ArangoDB Foxx
Michael Hackstein
 
Alfresco overview EDM
sang nguyen
 
Spring 3 - An Introduction
Thorsten Kamann
 
Share point development 101
Becky Bertram
 
Advanced guide to develop ajax applications using dojo
Fu Cheng
 
Introduction to Flask Micro Framework
Mohammad Reza Kamalifard
 
Building APIs in an easy way using API Platform
Antonio Peric-Mazar
 
Laravel 4 presentation
Abu Saleh Muhammad Shaon
 
PLAT-16 Using Enterprise Content in Grails
Alfresco Software
 
Play Framework and Activator
Kevin Webber
 
Alfresco Coding mit dem Alfresco SDK (auf Englisch) - Julien Bruinaud, Techni...
Nicole Szigeti
 
Integrating Alfresco with Portals
Piergiorgio Lucidi
 
WebNetConf 2012 - Single Page Apps
Pop Apps
 
Web Technologies in Java EE 7
Lukáš Fryč
 
CUST-2 New Client Configuration & Extension Points in Share
Alfresco Software
 
Progressive Web Apps and React
Mike Melusky
 
Ad

More from Alfresco Software (20)

PPTX
Alfresco Day Benelux Inholland studentendossier
Alfresco Software
 
PPTX
Alfresco Day Benelux Hogeschool Inholland Records Management application
Alfresco Software
 
PPTX
Alfresco Day BeNelux: Customer Success Showcase - Saxion Hogescholen
Alfresco Software
 
PPTX
Alfresco Day BeNelux: Customer Success Showcase - Gemeente Amsterdam
Alfresco Software
 
PPTX
Alfresco Day BeNelux: The success of Alfresco
Alfresco Software
 
PDF
Alfresco Day BeNelux: Customer Success Showcase - Credendo Group
Alfresco Software
 
PDF
Alfresco Day BeNelux: Digital Transformation - It's All About Flow
Alfresco Software
 
PDF
Alfresco Day Vienna 2016: Activiti – ein Katalysator für die DMS-Strategie be...
Alfresco Software
 
PDF
Alfresco Day Vienna 2016: Elektronische Geschäftsprozesse auf Basis von Alfre...
Alfresco Software
 
PDF
Alfresco Day Vienna 2016: Alfrescos neue Rest API
Alfresco Software
 
PDF
Alfresco Day Vienna 2016: Support Tools für die Admin-Konsole
Alfresco Software
 
PDF
Alfresco Day Vienna 2016: Entwickeln mit Alfresco
Alfresco Software
 
PDF
Alfresco Day Vienna 2016: Activiti goes enterprise: Die Evolution der BPM Sui...
Alfresco Software
 
PDF
Alfresco Day Vienna 2016: Partner Lightning Talk: Westernacher
Alfresco Software
 
PDF
Alfresco Day Vienna 2016: Bringing Content & Process together with the App De...
Alfresco Software
 
PDF
Alfresco Day Vienna 2016: Partner Lightning Talk - it-novum
Alfresco Software
 
PDF
Alfresco Day Vienna 2016: How to Achieve Digital Flow in the Enterprise - Joh...
Alfresco Software
 
PDF
Alfresco Day Warsaw 2016 - Czy możliwe jest spełnienie wszystkich regulacji p...
Alfresco Software
 
PDF
Alfresco Day Warsaw 2016: Identyfikacja i podpiselektroniczny - Safran
Alfresco Software
 
PDF
Alfresco Day Warsaw 2016: Advancing the Flow of Digital Business
Alfresco Software
 
Alfresco Day Benelux Inholland studentendossier
Alfresco Software
 
Alfresco Day Benelux Hogeschool Inholland Records Management application
Alfresco Software
 
Alfresco Day BeNelux: Customer Success Showcase - Saxion Hogescholen
Alfresco Software
 
Alfresco Day BeNelux: Customer Success Showcase - Gemeente Amsterdam
Alfresco Software
 
Alfresco Day BeNelux: The success of Alfresco
Alfresco Software
 
Alfresco Day BeNelux: Customer Success Showcase - Credendo Group
Alfresco Software
 
Alfresco Day BeNelux: Digital Transformation - It's All About Flow
Alfresco Software
 
Alfresco Day Vienna 2016: Activiti – ein Katalysator für die DMS-Strategie be...
Alfresco Software
 
Alfresco Day Vienna 2016: Elektronische Geschäftsprozesse auf Basis von Alfre...
Alfresco Software
 
Alfresco Day Vienna 2016: Alfrescos neue Rest API
Alfresco Software
 
Alfresco Day Vienna 2016: Support Tools für die Admin-Konsole
Alfresco Software
 
Alfresco Day Vienna 2016: Entwickeln mit Alfresco
Alfresco Software
 
Alfresco Day Vienna 2016: Activiti goes enterprise: Die Evolution der BPM Sui...
Alfresco Software
 
Alfresco Day Vienna 2016: Partner Lightning Talk: Westernacher
Alfresco Software
 
Alfresco Day Vienna 2016: Bringing Content & Process together with the App De...
Alfresco Software
 
Alfresco Day Vienna 2016: Partner Lightning Talk - it-novum
Alfresco Software
 
Alfresco Day Vienna 2016: How to Achieve Digital Flow in the Enterprise - Joh...
Alfresco Software
 
Alfresco Day Warsaw 2016 - Czy możliwe jest spełnienie wszystkich regulacji p...
Alfresco Software
 
Alfresco Day Warsaw 2016: Identyfikacja i podpiselektroniczny - Safran
Alfresco Software
 
Alfresco Day Warsaw 2016: Advancing the Flow of Digital Business
Alfresco Software
 
Ad

Recently uploaded (20)

DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 

PLAT-7 Spring Web Scripts and Spring Surf

  • 1. Spring Surf & Web Scripts! Dave Draper – UI Engineer - @_DaveDraper!
  • 2. History lesson... 2007 • Alfresco 2.0 introduces first REST API (early WebScripts concepts)! • Alfresco 2.1 introduces WebScripts! • REST framework, JSR-311 (Jax-RS) URI Index! • Scriptable controllers (or backed by Spring Java Beans)! • FreeMarker template output (or Java output stream)! 2008 • Alfresco Web Framework demo-ware (model objects, JSP, FTL)! • Alfresco Page Render (WebScripts as components on a page)! • Combined, productised and renamed to Surf! • Alfresco Share 3.0, 3.1 – Alfresco collaboration and DM – modern XHTML and Ajax based interface!
  • 3. History lesson (cont)... Early 2009 • Alfresco Share 3.2! • First contact between Alfresco and Spring Source! Late 2009 • Alfresco Surf and WebScripts integrated with Spring MVC! • Alfresco Surf and WebScripts contributed as Spring Extension – Spring WebScripts and Spring Surf! • Alfresco Share 3.3 – refactored onto Spring WebScripts and Spring Surf!! 2010 • 3 Milestones and RC1 release! • Alfresco Share 3.4 – using SpringSurf RC1!
  • 4. History lesson (cont)... 2011 • Alfresco Team! • New extensibility capabilities added! • Version 1.0.0 releases! • Alfresco Share 4.0!
  • 5. What Are WebScripts? • Services bound to a URIs which respond to HTTP methods such as GET, POST, PUT and DELETE! • Support multiple formats (HTML, JSON & XML)! • A framework for creating a REST API! • Made up of descriptor, controller, properties, configuration and presentation files!
  • 6. WebScripts! • Descriptor (XML) • Controller (JavaScript/Java Spring Bean) • Response Formats (FreeMarker) • I18N properties (Text) • Configuration (XML)
  • 7. Response Formats! •  Available formats • HTML! • Text! • XML! • ATOM! • RSS! • JSON! •  Set default in Descriptor (if more than one available) •  Request by: • Extension (e.g. /script1.html, /script1.json, etc)! • Format request parameter (e.g. /script1?format=xml)!
  • 8. Why Use Web Scripts? •  Rapid development (no server restarts) •  Separation of concerns (MVC) •  Localization •  Extensibility •  FreeMarker and JavaScript
  • 9. But What Is Spring Surf ? •  An extension to Spring MVC •  A set of controllers, resolvers and views •  A way of breaking an HTML page into re- usable composite parts •  An interface to the Alfresco Repository •  The framework that underpins Alfresco Share
  • 10. Example Spring Surf Objects •  Pages •  Template Instances •  Regions •  Chrome •  Components •  Sub-Components
  • 11. Sub-­‐ Component   Component   Region   Region-­‐Chrome   Components   Chrome   Template-­‐Instance   Page  
  • 12. Mistakes were made… •  Chrome •  Scopes •  No Component nesting •  1-1 Region/Component binding •  Spring Roo •  Tools •  Difficult to match output to source
  • 13. …but there is lots of good stuff ! •  Themes •  Model Object stores (file system, classpath, remote, etc) •  Presets / object creation •  URI templates •  Remote connections •  Authentication •  Extensibility •  Endlessly configurable
  • 14. What can you do with it? • Rapid web-tier view composition – Spring MVC View Resolver! • FreeMarker, JSP, Groovy, PHP pages! • WebScript, FTL, JSP, Groovy, PHP components! • Simple JavaScript, Groovy controllers! • Remote API – REST request/response processing! • WebScripts – standalone REST API tier! • Portlets!
  • 15. What you SHOULD do with it?! • Customize Alfresco Share! • Use WebScripts and FreeMarker! • Use JavaScript controllers! • Use Endpoints to contact an Alfresco Repository in standalone applications!
  • 17. WebScript and Surf Object lookup!
  • 18. Authentication (WebScripts & Surf Pages)! •  Use <authentication> element •  Available types: • “none”! • “guest”! • “user”! • “admin”! •  Authenticates against Alfresco Repository •  Can use “runas” property with WebScripts only
  • 19. URI Templates (WebScripts)! •  Use tokens in URL • e.g. “/x/{token1}/y/{token2}/z”! •  Can define multiple URLs in single descriptor •  Use “url.templateArgs” to access • ${url.templateArgs.token1}!
  • 20. URI Templates (Surf Pages)! •  Define “uri-template” in <alfresco-config> (e.g. “share-config- custom.xml) • Include {pageid} token for Page mapping! • Or ensure Page exists (e.g. Created through Preset)! •  Use page.url.templateArgs to access tokens • e.g. ${page.url.templateArgs.token1}!
  • 21. Surf Configuration! •  Configuration object • Site home page! • Site theme! •  Surf.xml • Object type implementations (e.g. AdvancedComponent)! • User factories! • Site configuration! • Chrome! • Page type (e.g. Login)! • Module Deployment! •  Spring Application Context • Services (configuration loading, user factories, persistence, remote access, etc)! • Controllers (login controllers, etc)! • Interceptors!
  • 22. Custom Home Page! •  From: http://blogs.alfresco.com/wp/ddraper/2011/11/01/advanced- share-customization-part-1/ •  Optionally override <site-configuration> in “surf.xml” • Default is “slingshot.site.configuration”! •  Set <root-page> property in Configuration object
  • 23. Custom Login Page! •  From: http://blogs.alfresco.com/wp/ddraper/2011/11/03/advanced- share-customization-part-2/ •  Create Page and Template-Instance objects for custom login page •  Define new default “login” Page-Type object
  • 24. Regions and Components •  Regions define location into which Components can be bound •  Binding done through region-id, source-id and scope o  Forced 1-1 bindings o  Flawed concept for Component switching •  Sub-Components introduced as a workaround •  Components SHOULD use ComponentType or Processor but are “optimized” to use WebScript URL
  • 25. Remote API • Connectors & Authenticators! • XML configure access to “endpoints” – obtained by id! • Access HTTP methods through JavaScript controller or Ajax via proxy controller! • Endpoints hide the URL stem from scripts – authentication encapsulated by connectors and authenticators! • Connect to multiple REST sources; alfresco, wiki, search!
  • 26. Remote API – Example! var conn = remote.connect("alfresco"); var json = conn.get("/api/products/" + args.filter); if (json.status == 200) { // Create JavaScript objects from the response var obj = eval('(' + json + ')'); if (obj) { // Perform processing on the js objects // set results into the model for the template model.results = somearray; } }
  • 27. Model Object Stores • Persisters – read model object definitions from classpath, WEB-INF, JARs! • Alfresco legacy locations and Spring “friendly” locations! o Migration of Alfresco Surf 3.2 apps! o New locations require less files, folders! • Read and write to remote location and local file system! • Example - Alfresco Share stores pages and components for dynamic dashboards in the repository!
  • 28. Component .head.ftl template! •  Allow WebScripts to add JavaScript and CSS dependencies into HTML <head> •  Use ${head} in Template Instance to output dependencies into <head> •  Use <@script> to automatically switch between .js and –min.js <link rel="stylesheet" type="text/css" href="${page.url.context}/ products/products.css" /> <script src="${page.url.context}/products/products.js"></script>
  • 29. Useful Runtime Tools •  /service/index o  Browse WebScripts o  WebScript refresh o  SurfBug toggle
  • 30. Roadmap! •  Forking from Spring back into Alfresco •  Continued development (more extensibility features, performance improvements) •  Continued use in Alfresco projects •  More blogging, forums and documentation
  • 31. How do I use it?! • You CAN SVN checkout, maven build: https://src.springframework.org/svn/se-surf/trunk! • You SHOULD use Alfresco Community JARs when available!
  • 32. Learn More! •  Blog posts: • http://blogs.alfresco.com/wp/ewinlof/! • http://blogs.alfresco.com/wp/kevinr/! • http://blogs.alfresco.com/wp/ddraper/! • http://mindthegab.com/! •  Alfresco Forum: “Surf Development”