SpringSurf 1012Kevin RoastUI Team Leader, Alfrescotwitter: @kevinroast
SpringSurf 1013IntroductionWho am I?What is this all about?Just a quick history lesson...What can you do with it?Why should you use it?Views, templates, components.URL mappingRemote APIHow do I use it?Where is it going and what is missing?
SpringSurf 10142007Alfresco 2.0 introduces first REST API (early WebScripts concepts)Alfresco 2.1 introduces WebScriptsREST framework, JSR-311 (Jax-RS) URI IndexScriptable controllers (or backed by Spring Java Beans)FreeMarker template output (or Java output stream)2008Alfresco Web Framework demo-ware (model objects, JSP, FTL)Alfresco Page Render (WebScripts as components on a page)Combined, productised and renamed to SurfAlfresco Share 3.0, 3.1 – Alfresco collaboration and DM – modern XHTML and Ajax based interfaceJust a quick history lesson...
SpringSurf 1015Early 2009Alfresco Share 3.2First contact between Alfresco and SpringSourceLate 2009Alfresco Surf and WebScripts integrated with SpringMVCAlfresco Surf and WebScripts contributed as Spring Extension – SpringWebScripts and SpringSurfAlfresco Share 3.3 – refactored onto SpringWebScripts and SpringSurf!20103 Milestones and RC1 releaseAlfresco Share 3.4 – using SpringSurf RC12010-2011?RC2, 1.0Just a quick history lesson...
SpringSurf 1016Rapid web-tier view composition – SpringMVC View ResolverFreeMarker, JSP, Groovy, PHP pagesWebScript, FTL, JSP, Groovy, PHP componentsSimple JavaScript, Groovy controllersRemote API – REST request/response processingWebScripts – standalone REST API tierPortlets (RC1)What can you do with it?
SpringSurf 1017View composition plug-in for Spring Web MVCVaried choice of scripting/templating technologiesSimple but powerful APIsURI template mappings – clean URLs, page reuseRapid *rapid* development cycleOutput any text format, any HTML format (i.e. XHTML, HTML5)Extensions for Alfresco Share – JAR packagingAlfresco Share, WebQS, OpenCMIS and Apache ActivitiDeveloper tools in progressContinuing development via SpringSourceWhy should you use it?
SpringSurf 1018Views (pages) – simple XML definitionFreeMarker HTML templates, simple DIV based structure, component bindings, that’s it.Page->Template->Componentproducts.xmlproducts.ftlRegion component bindingsViews, Templates, Components
SpringSurf Model9PagesHomeProfileProductsRegionsComponentvarconn = remote.connect("alfresco");varjson = conn.get("/api/products/" + args.filter);if (json.status == 200){   // Create JavaScript objects from the responsevarobj = eval('(' + json + ')');   if (obj)   {      ... Perform processing on the js objects      // set results into the model for the templatemodel.results = somearray;   }}Template Instance
SpringSurf 10110Everything is an object! Including component bindings.CRUD operations via web-tier JS APIEasy dynamic get/set of object propertiesobject.properties["name"] = value;new() and save() objects to persist dynamically i.e. Alfresco Share dashboardsModel Objects
SpringSurf Model11PageInstanceSiteConfigTemplate InstanceTemplateThemeTemplate typeRegionsChromeComponentBindingComponentComponent type
products.xml (page)12<?xml version='1.0' encoding='UTF-8'?><page>   <title>New Products Page</title>   <description>Page displaying newest products</description>   <template-instance>products-template</template-instance>   <authentication>user</authentication><components>      <component>         <region-id>productlist</region-id>         <url>/components/productlist?filter=new</url>      </component>   </components>   <properties>      <maxresults>100</maxresults>   </properties></page>
products-template.xml (template instance)13<?xml version='1.0' encoding='UTF-8'?><template-instance>   <title>Product Template</title>   <description>Common products template</description><template-type>products</template-type>   <components>      <component>         <region-id>treeview</region-id>         <url>/components/navigation/treeview</url>      </component>   </components></template-instance>
products.ftl14<html>   <head>${head}</head>   <body>      <div id="..." class="...">         <@region id="header" scope="global" />      </div>      <div>         <@region id="treeview" scope="template" />         <@region id="productlist" scope="page" />      </div>      <div>         <@region id="footer" scope="global" />      </div>   </body></html>
SpringSurf 10115Components defined in page XML are page scope – “single use” components specific to a particular page e.g. admin console widgetComponents defined in template instance XML are template scoped – e.g. common tree navigation componentCan define component bindings by declaration – like WebScript artifacts e.g. page.title.console.xmlGlobal scoped component – header, footer etc.Template scoped componentsPage scoped componentsComponent Scopes
SpringSurf 10116ChromeTemplate fragment executed to wrap “chrome” around a component – for example default “region” chrome:<div id="${htmlid}">   <@component/></div>ThemesObjects that encapsulate the information required to define a new look and feel for an appAlfresco Share 3.4 – good exampleChrome and Themes
SpringSurf 10117http://yourserver:8080/yourapp/products/all/products         /new/products/old/products        /bestselling/productsDon’t want to define multiple pages that do same thing (even with reuse of templates)Either want to reuse the same page instanceAnd or require some information from the urlCan use: urlrewrite.xmlCan use: UriTemplateconfigURL Mapping
UriTemplate configuration18<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>
SpringSurf 10119UI Components must “behave” and follow loose contractUsual WebScript artifacts – bound by URLI18N messages via localisable properties fileComponent configuration (XML) via config.xml fileGET/POST to page – automatic fall back to GET implHEAD template webscriptid.get.head.ftl${head}argsmapformdataform fields (including files)page, page.url, config, user, htmlidobjectsRequest Context - contextRequest parameters, attributes, headersWebScript Component APIs
SpringSurf 10120ConnectorsAuthenticatorsXML configure access to “endpoints” – obtained by idAccess HTTP methods through JS code or Ajax via proxy controllerEndpoints hide the URL stem from scripts – authentication encapsulated by connectors and authenticators<endpoint>	<id>alfresco</id>	<name>Alfresco - user access</name>	<connector-id>alfresco</connector-id>	<endpoint-url>http://myserver/alfresco/s</endpoint-url>	<identity>user</identity></endpoint>Connect to multiple REST sources; alfresco, wiki, searchRemoting API
Remote API – component controller21products.get.jsvarconn = remote.connect("alfresco");varjson = conn.get("/api/products/" + args.filter);if (json.status == 200){   // Create JavaScript objects from the responsevarobj = eval('(' + json + ')');   if (obj)   {      ... Perform processing on the js objects      // set results into the model for the templatemodel.results = somearray;   }}
Remote API – component template22products.get.html.ftl<div class="products" id="${htmlid}-products">   <#list results as r>   <div class="product">Name: ${r.name?html}</div>   </#list></div>
Component .head.ftl template23products.get.head.ftl<link rel="stylesheet" type="text/css" href="${page.url.context}/products/products.css" /><script src="${page.url.context}/products/products.js"></script>
SpringSurf 10124Persisters – read model object definitions from classpath, WEB-INF, JARsAlfresco legacy locations and Spring “friendly” locationsMigration of Alfresco Surf 3.2 appsNew locations require less files, foldersRead and write to remote location and local file systemExample - Alfresco Share stores pages and components for dynamic dashboards in the repositoryModel Object Stores
Remote Persister Spring Config25<bean id="webframework.slingshot.persister.remote"   class="org.springframework.extensions.surf.persister.PathStoreObjectPersister” parent="webframework.sitedata.persister.abstract">   <property name="store" ref="webframework.webapp.store.remote" />   <property name="pathPrefix">      <value>alfresco/site-data/${objectTypeIds}</value>   </property></bean><bean id="webframework.objects.persister" class="org.springframework.extensions.surf.persister.MultiObjectPersister">   <property name="serviceRegistry" ref="webframework.service.registry" />   <property name="persisters">      <list>         <!-- Slingshot remote store persisters -->         <ref bean="webframework.slingshot.persister.remote" />         ...      </list>   </property>   <property name="defaultPersister">      <ref bean="webframework.slingshot.persister.remote" />   </property></bean>
Page, templates, components, webscripts – ALL dynamically refresh via WebScripts and Surf console pages/service/index/service/consoleConsole Information ViewRefresh WebScripts, Refresh Object RegistryUse exploded WAR folders/files during development – copy over and RefreshSpringSurf 10126Rapid Development Lifecycle
Development Configuration (surf.xml)27<alfresco-config>	<config evaluator="string-compare" condition="WebFramework">		<web-framework>			<!-- Autowire Runtime Settings -->			<autowire>			    <!-- Runtime: classpath, webapp, local, alfresco -->				    <!-- <runtime>classpath</runtime> -->			    <runtime>webapp</runtime>			    <!-- <runtime>local</runtime> -->			    <!-- <runtime>alfresco</runtime> -->			    <!-- Pick the mode: development, production -->			    			    <mode>development</mode>			    <!-- <mode>production</mode> -->			</autowire>		</web-framework>	</config></alfresco-config>
SpringSurf 10128SVN checkout, maven build – www.springsurf.orghttps://src.springframework.org/svn/se-surf/trunkhttps://src.springframework.org/svn/se-surf/tags/release-1.0.0-RC1Maven projectExample application WAR files (initial config etc.)Quick Start, Spring Pet Clinic, Spring TravelLook at Share, WebQS, Mobile, Activiti...Dev tools!How do I use it?
SpringSurf 10129Alfresco Share JAR file extensionsAdd or extend Alfresco features via simple JAR file packagingDrop in JAR to Share, restart app-server – done.See Alfresco blogs:alfresco-share-33-extensions-and-springsurfHow do I use it?
SpringSurf 10130Continue use by Alfresco projects, customers, partners...DOCUMENTATION!!! (sorry)Where is it going and what is missing?
Learn More31Blog posts:http://blogs.alfresco.com/wp/ewinlof/http://blogs.alfresco.com/wp/kevinr/http://mindthegab.com/http://drquyong.com/myblog/SpringSurf site and forums:http://www.springsurf.orghttp://forum.springsource.org/forumdisplay.php?f=72

More Related Content

PPT
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
PDF
Symfony2, Backbone.js &amp; socket.io - SfLive Paris 2k13 - Wisembly
PPT
Facelets
PPT
Building Single Page Application (SPA) with Symfony2 and AngularJS
PPT
Apache Camel - WJax 2008
PPT
Processing XML with Java
PDF
Myfacesplanet
PDF
Jsfandsecurity
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Symfony2, Backbone.js &amp; socket.io - SfLive Paris 2k13 - Wisembly
Facelets
Building Single Page Application (SPA) with Symfony2 and AngularJS
Apache Camel - WJax 2008
Processing XML with Java
Myfacesplanet
Jsfandsecurity

What's hot (20)

PPT
Jsfsunum
PPT
Red5 - PHUG Workshops
PDF
14 Fr 13 Civici Component Library Showdown
PPT
EPiServer Web Parts
PPT
Facelets
ODP
IBM Lotus Notes Domino XPages and XPages for Mobile
PDF
Creating GUI container components in Angular and Web Components
PDF
Creating GUI Component APIs in Angular and Web Components
PPT
What's new in Rails 2?
ZIP
Looking into HTML5
ODP
Apache Aries Blog Sample
PDF
WordPress APIs
PDF
Basic Crud In Django
PPT
WordPress and Ajax
PPT
KEY
Intro to html5 Boilerplate
PPTX
Service approach for development REST API in Symfony2
PPT
GHC
PDF
OSDC 2009 Rails Turtorial
PPT
Short Intro to PHP and MySQL
Jsfsunum
Red5 - PHUG Workshops
14 Fr 13 Civici Component Library Showdown
EPiServer Web Parts
Facelets
IBM Lotus Notes Domino XPages and XPages for Mobile
Creating GUI container components in Angular and Web Components
Creating GUI Component APIs in Angular and Web Components
What's new in Rails 2?
Looking into HTML5
Apache Aries Blog Sample
WordPress APIs
Basic Crud In Django
WordPress and Ajax
Intro to html5 Boilerplate
Service approach for development REST API in Symfony2
GHC
OSDC 2009 Rails Turtorial
Short Intro to PHP and MySQL
Ad

Similar to Spring Surf 101 (20)

PPT
Introduction to Alfresco Surf Platform
PPT
Strutsjspservlet
PPT
Struts,Jsp,Servlet
PPT
Strutsjspservlet
PPT
Creating Yahoo Mobile Widgets
PPT
Flex_rest_optimization
PPT
Internet Explorer 8 for Developers by Christian Thilmany
PPT
New Browsers
PPTX
Alfresco Search Internals
ODP
ActiveWeb: Chicago Java User Group Presentation
PPT
Enterprise Google Gadgets Integrated with Alfresco - Open Source ECM
PPT
Introducing Struts 2
PPT
Struts2
PPT
GTLAB Installation Tutorial for SciDAC 2009
ODP
Exploring Symfony's Code
PPTX
Speed up your developments with Symfony2
PPT
Introduction To ASP.NET MVC
PPTX
Spine.js
PDF
Intro To Mvc Development In Php
Introduction to Alfresco Surf Platform
Strutsjspservlet
Struts,Jsp,Servlet
Strutsjspservlet
Creating Yahoo Mobile Widgets
Flex_rest_optimization
Internet Explorer 8 for Developers by Christian Thilmany
New Browsers
Alfresco Search Internals
ActiveWeb: Chicago Java User Group Presentation
Enterprise Google Gadgets Integrated with Alfresco - Open Source ECM
Introducing Struts 2
Struts2
GTLAB Installation Tutorial for SciDAC 2009
Exploring Symfony's Code
Speed up your developments with Symfony2
Introduction To ASP.NET MVC
Spine.js
Intro To Mvc Development In Php
Ad

More from Alfresco Software (20)

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

Recently uploaded (20)

PDF
Transform-Your-Factory-with-AI-Driven-Quality-Engineering.pdf
PDF
Electrocardiogram sequences data analytics and classification using unsupervi...
PDF
Rapid Prototyping: A lecture on prototyping techniques for interface design
PPTX
Training Program for knowledge in solar cell and solar industry
PDF
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
PDF
Data Virtualization in Action: Scaling APIs and Apps with FME
PDF
The-2025-Engineering-Revolution-AI-Quality-and-DevOps-Convergence.pdf
PDF
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf
PDF
Ensemble model-based arrhythmia classification with local interpretable model...
PDF
EIS-Webinar-Regulated-Industries-2025-08.pdf
PDF
IT-ITes Industry bjjbnkmkhkhknbmhkhmjhjkhj
PDF
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
PDF
INTERSPEECH 2025 「Recent Advances and Future Directions in Voice Conversion」
PDF
zbrain.ai-Scope Key Metrics Configuration and Best Practices.pdf
PDF
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
PPTX
Internet of Everything -Basic concepts details
PDF
LMS bot: enhanced learning management systems for improved student learning e...
PDF
Transform-Your-Streaming-Platform-with-AI-Driven-Quality-Engineering.pdf
PDF
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
PPTX
agenticai-neweraofintelligence-250529192801-1b5e6870.pptx
Transform-Your-Factory-with-AI-Driven-Quality-Engineering.pdf
Electrocardiogram sequences data analytics and classification using unsupervi...
Rapid Prototyping: A lecture on prototyping techniques for interface design
Training Program for knowledge in solar cell and solar industry
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
Data Virtualization in Action: Scaling APIs and Apps with FME
The-2025-Engineering-Revolution-AI-Quality-and-DevOps-Convergence.pdf
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf
Ensemble model-based arrhythmia classification with local interpretable model...
EIS-Webinar-Regulated-Industries-2025-08.pdf
IT-ITes Industry bjjbnkmkhkhknbmhkhmjhjkhj
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
INTERSPEECH 2025 「Recent Advances and Future Directions in Voice Conversion」
zbrain.ai-Scope Key Metrics Configuration and Best Practices.pdf
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
Internet of Everything -Basic concepts details
LMS bot: enhanced learning management systems for improved student learning e...
Transform-Your-Streaming-Platform-with-AI-Driven-Quality-Engineering.pdf
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
agenticai-neweraofintelligence-250529192801-1b5e6870.pptx

Spring Surf 101

  • 1. SpringSurf 1012Kevin RoastUI Team Leader, Alfrescotwitter: @kevinroast
  • 2. SpringSurf 1013IntroductionWho am I?What is this all about?Just a quick history lesson...What can you do with it?Why should you use it?Views, templates, components.URL mappingRemote APIHow do I use it?Where is it going and what is missing?
  • 3. SpringSurf 10142007Alfresco 2.0 introduces first REST API (early WebScripts concepts)Alfresco 2.1 introduces WebScriptsREST framework, JSR-311 (Jax-RS) URI IndexScriptable controllers (or backed by Spring Java Beans)FreeMarker template output (or Java output stream)2008Alfresco Web Framework demo-ware (model objects, JSP, FTL)Alfresco Page Render (WebScripts as components on a page)Combined, productised and renamed to SurfAlfresco Share 3.0, 3.1 – Alfresco collaboration and DM – modern XHTML and Ajax based interfaceJust a quick history lesson...
  • 4. SpringSurf 1015Early 2009Alfresco Share 3.2First contact between Alfresco and SpringSourceLate 2009Alfresco Surf and WebScripts integrated with SpringMVCAlfresco Surf and WebScripts contributed as Spring Extension – SpringWebScripts and SpringSurfAlfresco Share 3.3 – refactored onto SpringWebScripts and SpringSurf!20103 Milestones and RC1 releaseAlfresco Share 3.4 – using SpringSurf RC12010-2011?RC2, 1.0Just a quick history lesson...
  • 5. SpringSurf 1016Rapid web-tier view composition – SpringMVC View ResolverFreeMarker, JSP, Groovy, PHP pagesWebScript, FTL, JSP, Groovy, PHP componentsSimple JavaScript, Groovy controllersRemote API – REST request/response processingWebScripts – standalone REST API tierPortlets (RC1)What can you do with it?
  • 6. SpringSurf 1017View composition plug-in for Spring Web MVCVaried choice of scripting/templating technologiesSimple but powerful APIsURI template mappings – clean URLs, page reuseRapid *rapid* development cycleOutput any text format, any HTML format (i.e. XHTML, HTML5)Extensions for Alfresco Share – JAR packagingAlfresco Share, WebQS, OpenCMIS and Apache ActivitiDeveloper tools in progressContinuing development via SpringSourceWhy should you use it?
  • 7. SpringSurf 1018Views (pages) – simple XML definitionFreeMarker HTML templates, simple DIV based structure, component bindings, that’s it.Page->Template->Componentproducts.xmlproducts.ftlRegion component bindingsViews, Templates, Components
  • 8. SpringSurf Model9PagesHomeProfileProductsRegionsComponentvarconn = remote.connect("alfresco");varjson = conn.get("/api/products/" + args.filter);if (json.status == 200){ // Create JavaScript objects from the responsevarobj = eval('(' + json + ')'); if (obj) { ... Perform processing on the js objects // set results into the model for the templatemodel.results = somearray; }}Template Instance
  • 9. SpringSurf 10110Everything is an object! Including component bindings.CRUD operations via web-tier JS APIEasy dynamic get/set of object propertiesobject.properties["name"] = value;new() and save() objects to persist dynamically i.e. Alfresco Share dashboardsModel Objects
  • 10. SpringSurf Model11PageInstanceSiteConfigTemplate InstanceTemplateThemeTemplate typeRegionsChromeComponentBindingComponentComponent type
  • 11. products.xml (page)12<?xml version='1.0' encoding='UTF-8'?><page> <title>New Products Page</title> <description>Page displaying newest products</description> <template-instance>products-template</template-instance> <authentication>user</authentication><components> <component> <region-id>productlist</region-id> <url>/components/productlist?filter=new</url> </component> </components> <properties> <maxresults>100</maxresults> </properties></page>
  • 12. products-template.xml (template instance)13<?xml version='1.0' encoding='UTF-8'?><template-instance> <title>Product Template</title> <description>Common products template</description><template-type>products</template-type> <components> <component> <region-id>treeview</region-id> <url>/components/navigation/treeview</url> </component> </components></template-instance>
  • 13. products.ftl14<html> <head>${head}</head> <body> <div id="..." class="..."> <@region id="header" scope="global" /> </div> <div> <@region id="treeview" scope="template" /> <@region id="productlist" scope="page" /> </div> <div> <@region id="footer" scope="global" /> </div> </body></html>
  • 14. SpringSurf 10115Components defined in page XML are page scope – “single use” components specific to a particular page e.g. admin console widgetComponents defined in template instance XML are template scoped – e.g. common tree navigation componentCan define component bindings by declaration – like WebScript artifacts e.g. page.title.console.xmlGlobal scoped component – header, footer etc.Template scoped componentsPage scoped componentsComponent Scopes
  • 15. SpringSurf 10116ChromeTemplate fragment executed to wrap “chrome” around a component – for example default “region” chrome:<div id="${htmlid}"> <@component/></div>ThemesObjects that encapsulate the information required to define a new look and feel for an appAlfresco Share 3.4 – good exampleChrome and Themes
  • 16. SpringSurf 10117http://yourserver:8080/yourapp/products/all/products /new/products/old/products /bestselling/productsDon’t want to define multiple pages that do same thing (even with reuse of templates)Either want to reuse the same page instanceAnd or require some information from the urlCan use: urlrewrite.xmlCan use: UriTemplateconfigURL Mapping
  • 17. UriTemplate configuration18<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>
  • 18. SpringSurf 10119UI Components must “behave” and follow loose contractUsual WebScript artifacts – bound by URLI18N messages via localisable properties fileComponent configuration (XML) via config.xml fileGET/POST to page – automatic fall back to GET implHEAD template webscriptid.get.head.ftl${head}argsmapformdataform fields (including files)page, page.url, config, user, htmlidobjectsRequest Context - contextRequest parameters, attributes, headersWebScript Component APIs
  • 19. SpringSurf 10120ConnectorsAuthenticatorsXML configure access to “endpoints” – obtained by idAccess HTTP methods through JS code or Ajax via proxy controllerEndpoints hide the URL stem from scripts – authentication encapsulated by connectors and authenticators<endpoint> <id>alfresco</id> <name>Alfresco - user access</name> <connector-id>alfresco</connector-id> <endpoint-url>http://myserver/alfresco/s</endpoint-url> <identity>user</identity></endpoint>Connect to multiple REST sources; alfresco, wiki, searchRemoting API
  • 20. Remote API – component controller21products.get.jsvarconn = remote.connect("alfresco");varjson = conn.get("/api/products/" + args.filter);if (json.status == 200){ // Create JavaScript objects from the responsevarobj = eval('(' + json + ')'); if (obj) { ... Perform processing on the js objects // set results into the model for the templatemodel.results = somearray; }}
  • 21. Remote API – component template22products.get.html.ftl<div class="products" id="${htmlid}-products"> <#list results as r> <div class="product">Name: ${r.name?html}</div> </#list></div>
  • 22. Component .head.ftl template23products.get.head.ftl<link rel="stylesheet" type="text/css" href="${page.url.context}/products/products.css" /><script src="${page.url.context}/products/products.js"></script>
  • 23. SpringSurf 10124Persisters – read model object definitions from classpath, WEB-INF, JARsAlfresco legacy locations and Spring “friendly” locationsMigration of Alfresco Surf 3.2 appsNew locations require less files, foldersRead and write to remote location and local file systemExample - Alfresco Share stores pages and components for dynamic dashboards in the repositoryModel Object Stores
  • 24. Remote Persister Spring Config25<bean id="webframework.slingshot.persister.remote" class="org.springframework.extensions.surf.persister.PathStoreObjectPersister” parent="webframework.sitedata.persister.abstract"> <property name="store" ref="webframework.webapp.store.remote" /> <property name="pathPrefix"> <value>alfresco/site-data/${objectTypeIds}</value> </property></bean><bean id="webframework.objects.persister" class="org.springframework.extensions.surf.persister.MultiObjectPersister"> <property name="serviceRegistry" ref="webframework.service.registry" /> <property name="persisters"> <list> <!-- Slingshot remote store persisters --> <ref bean="webframework.slingshot.persister.remote" /> ... </list> </property> <property name="defaultPersister"> <ref bean="webframework.slingshot.persister.remote" /> </property></bean>
  • 25. Page, templates, components, webscripts – ALL dynamically refresh via WebScripts and Surf console pages/service/index/service/consoleConsole Information ViewRefresh WebScripts, Refresh Object RegistryUse exploded WAR folders/files during development – copy over and RefreshSpringSurf 10126Rapid Development Lifecycle
  • 26. Development Configuration (surf.xml)27<alfresco-config> <config evaluator="string-compare" condition="WebFramework"> <web-framework> <!-- Autowire Runtime Settings --> <autowire> <!-- Runtime: classpath, webapp, local, alfresco --> <!-- <runtime>classpath</runtime> --> <runtime>webapp</runtime> <!-- <runtime>local</runtime> --> <!-- <runtime>alfresco</runtime> --> <!-- Pick the mode: development, production --> <mode>development</mode> <!-- <mode>production</mode> --> </autowire> </web-framework> </config></alfresco-config>
  • 27. SpringSurf 10128SVN checkout, maven build – www.springsurf.orghttps://src.springframework.org/svn/se-surf/trunkhttps://src.springframework.org/svn/se-surf/tags/release-1.0.0-RC1Maven projectExample application WAR files (initial config etc.)Quick Start, Spring Pet Clinic, Spring TravelLook at Share, WebQS, Mobile, Activiti...Dev tools!How do I use it?
  • 28. SpringSurf 10129Alfresco Share JAR file extensionsAdd or extend Alfresco features via simple JAR file packagingDrop in JAR to Share, restart app-server – done.See Alfresco blogs:alfresco-share-33-extensions-and-springsurfHow do I use it?
  • 29. SpringSurf 10130Continue use by Alfresco projects, customers, partners...DOCUMENTATION!!! (sorry)Where is it going and what is missing?

Editor's Notes

  • #4: Quick bio:Kevin Roast - UI Team Leader, one of the founding Alfresco developers, worked on the Explorer JSF based client, the JavaScript and FreeMarker services and repository APIs, impl some of the features in Alfresco WebScripts, came up with the PageRenderer WebScript runtime which is the “core” of the SpringSurf rendering tech used in Alfresco Share – i.e. “WebScripts as UI components” – more on to that later…Introduction to SpringSurf – not a deep dive - we will examine the basics of the SpringSurf view composition framework for Spring MVC applications. Hope to show how to easy to construct pages, templates and components that can be used to quickly build web applications fromsimple scripts and templates.
  • #5: WebScripts been around for more than 3 years in some form or anotherSurf has been around for over 2 yearsElaborate on important points in the history
  • #6: M3 -&gt; RC1 we’ve come a long way...RC1 is a revelation compared to stability, performance and test coverage since M3... Features a large suite of tests for functional area coverage.
  • #7: What can you do with it? – Simple REST APIs to complete Rich web applications!WebScript pure REST API tier i.e. separate application – Activiti project; has a pure WebScript based REST API tier exposing new BPM engine (server), plus a SpringSurf based web-application consuming the REST APIs (UI). A mix of Java and JavaScript backed webscripts and FTL based pages &lt;- mention Erik’s blog posts, download Activiti etc.WebQS, Mobile.
  • #8: Why should you use it?Familiar with SpringMVC? Then this will make building views quicker, less (a lot less!) Java code (annotations yuk) and can use lovely WebScripts.Fast, powerful APIs, rapidRAPID dev cycle. Extend Share – jar packaging.Share uses it, WebQS, OpenCMIS and Activiti use itDeveloper tools coming!
  • #9: Views (pages), templates, components – WebScripts, FreeMarker, JS, head templates, JSP, chrome.Page, can specify template instance to use (another xml descriptor) – otherwise Surf will “use template with the same name” but can reuse templates i.e. a product template can be used by multiple pages. Reused of pages, templates.Components can be global, template or page scoped – also uri or theme scope – unique to the URL (mostly same as page, but not if you use URL templates) and theme specific
  • #10: Helps to identify the link between pages, template instances, templates and components
  • #11: Surf model objects can be created, modified and persisted – they all respond to APIs – think dynamic dashboards in Share – could have real-time drag and drop if you felt that would provide the best UI experience...
  • #12: Helps to identify the link between pages, template instances, templates and components
  • #13: Example page def – note embedded page scoped component defs (since 3.3)Custom properties
  • #14: If you have no template scoped components, or template specific properties - then you don’t need this! Surf will automatically attempt to find “products.ftl” and internally generate an intermediary object to represent the template instanceNote the embedded template scoped component defs
  • #15: Note the ${head} freemarker model value – combined result of all components .head.ftl templates – well formed HTMLRegion tags themselves can be dynamic!i.e.&lt;#list comps as c&gt;&lt;@region id=“${c}&quot; scope=“${something}&quot; /&gt;&lt;/#list&gt;Surf will work out what components are present on the page before pre-generating the ${head} contents.Simple DIV structure, use CSS for layout magic (also YUI in Share – entirely up to you what libs you use! JQuery etc.)Example template with region component bindings, examples of global, template and page scoped (next slide for detail)
  • #16: &lt;scope&gt;page&lt;/scope&gt; &lt;region-id&gt;title&lt;/region-id&gt; &lt;source-id&gt;console&lt;/source-id&gt;For uri/theme scopeWith nested components defs, only global scoped components tend to be defined in individual XML files – lot, lot less XML files than in 3.2 – see Share 3.4 for comparison!
  • #18: Allows simple urls and multiple URLs (i.e. Spring Views) to Share the same SpringSurf Page instance
  • #20: UI component WebScript component “contract”:Don’t output full page HTML i.e. Just an HTML fragmentOutput clean HTML consistent with parent page i.e. XHTML, HTML5Use .head.ftl template for dependant client-side files i.e. CSS, JSCan assume running in page context i.e. use of “page.url.args” is ok – but better to “bind” args into component URLEncode HTML with ?html and encode JS with ?js_string &lt;- XSS!
  • #22: If GET, can simplify to – remote.call(“/...”);Use eval() for JSON response – or use E4X to process XML responsePlace any processed JS objects into the “model” – generally an array of objects or just an object – will automatically be marshelled into FreeMarker object equivalents i.e Array to List, Object to MapCan just put the eval-ed resulting object directly into the model without further processing if required, but most scripts do some processing of the data in JS – remember if “production” mode the JS is compiled so quick (but not as quick as Java or modern JS engine like V8...)Get/post/put/delete on the connector objectImagine processing formdata form client, placing into a json structure and POSTing to an API – very quick and easy to do.
  • #23: Walk arrays as lists or access object properties from the model – easy and fast
  • #24: Full component model not available (special template – not running as a true WebScript presentation template) – but access to “page” etc. as you would expect i.e. args available
  • #26: Adding a persister via SpringSurfModel objects will now be retrieved from remote Alfresco store by default (cached of course)Model objects can be save()ed to the remote store
  • #28: Runtime: selects the “persister” group – WEB-INF (webapp), classpath locations (surf/), local is a folder on disk, alfresco is alfresco specific classpaths (alfresco/) i.e. Old Surf apps and Alfresco ShareDevelopment mode: selects the caching settings for the model objects loaded by the persitsers – runtime uses aggressive caching – will *need* to Refresh via console if adding files at runtime. The “development” mode disables caches. Note that WebScript components will still need Refresh-ing as the WebScript registry is populated once during server startup.
  • #30: Mention blog post on JAR packaging for ShareSince 3.4.b it is possible to override Share web-assets also (fixed to use the /res resource controller for all assets – so can override on classpath or JARs)