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 Web...
History lesson (cont)...Early 2009  • Alfresco Share 3.2!  • First contact between Alfresco and Spring Source!Late 2009  •...
History lesson (cont)...2011 • Alfresco Team! • New extensibility capabilities added! • Version 1.0.0 releases! • Alfresco...
What Are WebScripts?• Services bound to a URIs which respond to HTTP methods such as  GET, POST, PUT and DELETE!• Support ...
Why Use Web Scripts?•    Rapid development (no server restarts)•    Separation of concerns (MVC)•    Localization•    Exte...
But What Is Spring Surf ?•  An extension to Spring MVC•  A set of controllers, resolvers and views•  A way of breaking an ...
Example Spring Surf Objects•    Pages•    Template Instances•    Regions•    Chrome•    Components•    Sub-Components
Mistakes were made…•    Chrome•    Scopes•    No Component nesting•    1-1 Region/Component binding•    Spring Roo•    Too...
…but there is lots of good stuff !•     Themes•     Model Object stores (file system, classpath, remote,      etc)•     Pr...
What can you do with it?• Rapid web-tier view composition – Spring MVC View Resolver!• FreeMarker, JSP, Groovy, PHP pages!...
What you SHOULD do with it?• Customize Alfresco Share!• Use WebScripts and FreeMarker!• Use JavaScript controllers!• Use E...
SOME USEFUL INFORMATION!
UriTemplate configuration!Allow variable Pages to be mapped (e.g. Alfresco Share Dashboards) <config evaluator="string-comp...
Regions and Components•         Regions define location into which Components can          be bound•         Binding done ...
Remote API• Connectors & Authenticators!• XML configure access to “endpoints” – obtained by id!• Access HTTP methods throug...
Remote API – Example!var conn = remote.connect("alfresco");var json = conn.get("/api/products/" + args.filter);if (json.st...
Model Object Stores• Persisters – read model object definitions from classpath, WEB-  INF, JARs!• Alfresco legacy locations...
Component .head.ftl template!•      Allow WebScripts to add JavaScript and CSS dependencies into       HTML <head>•      U...
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  improve...
How do I use it?• You CAN SVN checkout, maven build:  https://src.springframework.org/svn/se-surf/trunk!• You SHOULD use A...
Learn More!•  Blog posts: • http://blogs.alfresco.com/wp/ewinlof/! • http://blogs.alfresco.com/wp/kevinr/! • http://blogs....
Questions?!
PLAT-8 Spring Web Scripts and Spring Surf
Upcoming SlideShare
Loading in...5
×

PLAT-8 Spring Web Scripts and Spring Surf

2,214

Published on

This session introduces the Spring Web Scripts and the Spring Surf framework describing how they are used to underpin the Alfresco Share user interface. As well as covering the basic concepts, this session will cover the history and future roadmap for the frameworks.

Published in: Technology, Education
1 Comment
4 Likes
Statistics
Notes
No Downloads
Views
Total Views
2,214
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
1
Likes
4
Embeds 0
No embeds

No notes for slide

PLAT-8 Spring Web Scripts and Spring Surf

  1. 1. Spring Surf & Web Scripts! Dave Draper – UI Engineer - @_DaveDraper!
  2. 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. 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. 4. History lesson (cont)...2011 • Alfresco Team! • New extensibility capabilities added! • Version 1.0.0 releases! • Alfresco Share 4.0!
  5. 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. 6. Why Use Web Scripts?•  Rapid development (no server restarts)•  Separation of concerns (MVC)•  Localization•  Extensibility•  FreeMarker and JavaScript
  7. 7. 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
  8. 8. Example Spring Surf Objects•  Pages•  Template Instances•  Regions•  Chrome•  Components•  Sub-Components
  9. 9. Mistakes were made…•  Chrome•  Scopes•  No Component nesting•  1-1 Region/Component binding•  Spring Roo•  Tools•  Difficult to match output to source
  10. 10. …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
  11. 11. 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!
  12. 12. 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!
  13. 13. SOME USEFUL INFORMATION!
  14. 14. UriTemplate configuration!Allow variable Pages to be mapped (e.g. Alfresco Share Dashboards) <config evaluator="string-compare" condition="UriTemplate"> <uri-templates> <uri-template id="products"> /{filter}/products </uri-template> <uri-template id="userprofile"> /user/{userid}/{pageid} </uri-template> </uri-templates> </config>
  15. 15. 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
  16. 16. 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!
  17. 17. 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; }}
  18. 18. 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!
  19. 19. 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>
  20. 20. Useful Runtime Tools•  /service/index o  Browse WebScripts o  WebScript refresh o  SurfBug toggle
  21. 21. Roadmap• Forking from Spring back into Alfresco!• Continued development (more extensibility features, performance improvements)!• Continued use in Alfresco projects!• More blogging, forums and documentation!
  22. 22. 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!
  23. 23. 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”
  24. 24. Questions?!

×