SlideShare uma empresa Scribd logo
1 de 24
Baixar para ler offline
Alfresco Surf Code Camp
Walkthrough 2: Adding CMIS to Green Energy
Objectives

             Place additional functionality into Green Energy Site
             Get exposed to CMIS by adding a component that lists
             the contents of a folder
             Use E4X to parse XML in JavaScript




07/11/08                                                             2
Green Energy

             We will extend the Green Energy site you started in
             Lab #3
             Sample location:
              • /opt/tomcat/webapps/alfwf
              • http://labs3c:8580/alfwf




07/11/08                                                           3
Directories

             Green Energy Web Application
              • /opt/tomcat/webapps/alfwf


             site-data
              • /WEB-INF/classes/alfresco/site-data
             site-webscripts
              • /WEB-INF/classes/alfresco/site-webscripts
             FreeMarker templates
              • /WEB-INF/classes/alfresco/templates




07/11/08                                                    4
Drop in assets

             Unzip the assets.zip file into the web application
             Manifest:
              • /images/age/folder.png
              • /images/age/page.png
              • /WEB-INF/classes/alfresco/templates/age/tools.ftl
              • /WEB-INF/classes/alfresco/site-webscripts/age/feed-util.js




07/11/08                                                                     5
Add a tools page

             Add a tools page
             Points to a rendering template: tools
             tools.xml
             /WEB-INF/classes/alfresco/site-data/pages
             <?xml version='1.0' encoding='UTF-8'?>
             <page>
                <title>Tools</title>
                <template-instance>tools</template-instance>
                <authentication>user</authentication>
             </page>


             The tools page must know how to render
              • Use template instance: tools




07/11/08                                                       6
Add a tools template instance

             Add a tools template instance
             Points to a FreeMarker file: /age/tools
             tools.xml
              • /WEB-INF/classes/alfresco/site-data/template-instances

                <?xml version='1.0' encoding='UTF-8'?>
                <template-instance>
                   <template-type>/age/tools</template-type>
                </template-instance>




             The template instance needs a renderer
              • The FreeMarker renderer:     /age/tools.ftl

              • You already unzipped this. It was in assets.zip




07/11/08                                                                 7
Tools Template




                                     navigation  template scope




                   left                         content
                page scope                     page scope




                             footer  global scope
07/11/08                                                          8
Bind in the navigation component

             Add a component binding for the navigation
             template.navigation.tools.xml
              • /WEB-INF/classes/alfresco/site-data/components
               <?xml version='1.0' encoding='UTF-8'?>
               <component>
                  <scope>template</scope>
                  <region-id>navigation</region-id>
                  <source-id>tools</source-id>
                  <url>/blocks/navigation</url>
               </component>

             Note: The footer will naturally bind as it is globally
             scoped.




07/11/08                                                              9
Add as a child of the home page

             Adds the ‘tools’ page as a child of the ‘home’ page
              • Page association
             home-tools.xml
              • /WEB-INF/classes/alfresco/site-data/page-associations

                <?xml version='1.0' encoding='UTF-8'?>
                <page-association>
                   <source-id>home</source-id>
                   <dest-id>tools</dest-id>
                   <assoc-type>child</assoc-type>
                </page-association>




07/11/08                                                                10
Try it out

             Start Alfresco
              • http://labs3c:8080/alfresco
             Start Surf Tomcat
              • http://labs3c:8580/alfwf
             Browse to
              • http://labs3c:8580/alfwf/service/index
             Click on ‘Refresh’ to reset the Web Scripts cache
             Test your site
              • http://labs3c:8580/alfwf




07/11/08                                                         11
Try it out




07/11/08                12
Add a FolderList Component

             Navigate to the site-webscripts directory
              • /WEB-INF/classes/alfresco/site-webscripts
             Create a folder called age
             Navigate into the age directory
              • /WEB-INF/classes/alfresco/site-webscripts/age
             Create a Web Script:
              • folderlist




07/11/08                                                        13
FolderList Component

             Create a web script with the following url
              • /age/folderlist
             folderlist.get.desc.xml
             <webscript>
                <shortname>Folder Listing</shortname>
                <description>Provides a list of contents under Company Home</description>
                <url>/age/folderlist</url>
             </webscript>




07/11/08                                                                                14
FolderList Component

             folderlist.get.properties
             folderlist.name = Folder Listing




07/11/08                                        15
FolderList Component

             folderlist.get.js
             <import resource=quot;classpath:alfresco/site-webscripts/age/feed.utils.jsquot;>

             // TODO: Load the feed
             var feed = null;

             // TODO: convert feed to JavaScript
             var xml = null;

             // set up the model
             model.title = xml.*::title.toString();
             var items = new Array();
             for each (entry in xml.*::entry)
             {
                  var item = { };

                      // TODO: retrieve title value
                 item[quot;titlequot;] = null;

                      // TODO: retrieve icon value
                 item[quot;iconquot;] = null;

                  items.push(item);
             }
             model.items = items;


07/11/08                                                                                16
Notes
           FolderList Component
             Loading the feed
              • Recommended API (CMIS)
              • /api/path/workspace/SpacesStore/<path>/children
              • Example: /api/path/workspace/SpacesStore/Company%20Home/children

             Convert the feed to JavaScript
              • Helper function defined in import
              • var xmlObject = loadFeed(feed);
              • <import resource=quot;classpath:alfresco/site-webscripts/age/feed.utils.jsquot;>

             Set up the model
              • Namespace aware
              • Use namespace independent way of pulling properties
              • var value = node.*::propertyName.toString();

             More info on E4X
              • http://www.ibm.com/developerworks/library/ws-ajax1/




07/11/08                                                                                   17
FolderList Component

             folderlist.get.html.ftl
             <div>
                <div class=quot;titlequot;>TODO#1</div>
                <div class=quot;bodyquot;>
                   <h2>TODO#2</h2>
                   <ul>
                   <#list items as item>
                      <li><img src=“TODO#3quot;/>&nbsp;TODO#4</li>
                   </#list>
                   </ul>
                </div>
             </div>




07/11/08                                                         18
Notes
           FolderList Component
             TODO #1
              • Insert value of folderlist.name from properties file
              • Syntax: ${msg(string)}
             TODO #2
              • Insert value of title from model
              • Syntax: ${variableName} or ${object.variableName}
             TODO #3
              • Insert value of icon from items array
              • Syntax: ${variableName} or ${object.variableName}
             TODO #4
              • Insert value of title from items array
              • Syntax: ${variableName} or ${object.variableName}




07/11/08                                                               19
Bind in the FolderList component

             Add a component binding for the FolderList
             component
             page.content.tools.xml
              • /WEB-INF/classes/alfresco/site-data/components

               <?xml version='1.0' encoding='UTF-8'?>
               <component>
                  <scope>page</scope>
                  <region-id>content</region-id>
                  <source-id>tools</source-id>
                  <url>/age/folderlist</url>
               </component>




07/11/08                                                         20
Try it out

             Start Alfresco
              • http://labs3c:8080/alfresco
             Start Surf Tomcat
              • http://labs3c:8580/alfwf
             Browse to
              • http://labs3c:8580/alfwf/service/index
             Click on ‘Refresh’ to reset the Web Scripts cache
             Test your site
              • http://labs3c:8580/alfwf




07/11/08                                                         21
Try it out




07/11/08                22
Try it out

             Potential problem: Images not showing up
              • http://localhost:8080/alfresco/images/xyz.gif
              • http://labs3c:8580/alfresco/images/xyz.gif
              • Hack: entry.*::icon.toString().replace('localhost', 'labs3c');




07/11/08                                                                         23
Wrap-up

                 In this walkthrough, you...
                     • Added a new page called Tools
                     • Bound a new “folderlist” component to a region on the Tools page
                     • Implemented the folderlist component to use a CMIS call to
                       retrieve the folder contents of a specified path
                     • Used E4X to parse the XML that CMIS returned




07/11/08   Optaros and Client confidential. All rights reserved.                          24

Mais conteúdo relacionado

Mais procurados (10)

HTML5 kickstart - Brooklyn Beta workshop 21.10.2010
HTML5 kickstart - Brooklyn Beta workshop 21.10.2010HTML5 kickstart - Brooklyn Beta workshop 21.10.2010
HTML5 kickstart - Brooklyn Beta workshop 21.10.2010
 
JSUG - Maven by Michael Greifeneder
JSUG - Maven by Michael GreifenederJSUG - Maven by Michael Greifeneder
JSUG - Maven by Michael Greifeneder
 
HTML5 and friends - Institutional Web Management Workshop 2010
HTML5 and friends - Institutional Web Management Workshop 2010HTML5 and friends - Institutional Web Management Workshop 2010
HTML5 and friends - Institutional Web Management Workshop 2010
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress Plugin
 
Html servlet example
Html   servlet exampleHtml   servlet example
Html servlet example
 
Ant User Guide
Ant User GuideAnt User Guide
Ant User Guide
 
AIR 開發應用程式實務
AIR 開發應用程式實務AIR 開發應用程式實務
AIR 開發應用程式實務
 
Firefox OS workshop, JSFoo, India
Firefox OS workshop, JSFoo, IndiaFirefox OS workshop, JSFoo, India
Firefox OS workshop, JSFoo, India
 
Desmistificando o Phonegap (Cordova)
Desmistificando o Phonegap (Cordova)Desmistificando o Phonegap (Cordova)
Desmistificando o Phonegap (Cordova)
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails Turtorial
 

Semelhante a Optaros Surf Code Camp Walkthrough 2

Step by Step Guide for building a simple Struts Application
Step by Step Guide for building a simple Struts ApplicationStep by Step Guide for building a simple Struts Application
Step by Step Guide for building a simple Struts Application
elliando dias
 
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.frameworkHanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
Nguyen Duc Phu
 
Terracotta Ch'ti Jug
Terracotta Ch'ti JugTerracotta Ch'ti Jug
Terracotta Ch'ti Jug
Ch'ti JUG
 
Mobile library on drupal cil2011
Mobile library on drupal   cil2011Mobile library on drupal   cil2011
Mobile library on drupal cil2011
sc20866
 

Semelhante a Optaros Surf Code Camp Walkthrough 2 (20)

Optaros Surf Code Camp Walkthrough 1
Optaros Surf Code Camp Walkthrough 1Optaros Surf Code Camp Walkthrough 1
Optaros Surf Code Camp Walkthrough 1
 
Step by Step Guide for building a simple Struts Application
Step by Step Guide for building a simple Struts ApplicationStep by Step Guide for building a simple Struts Application
Step by Step Guide for building a simple Struts Application
 
Optaros Surf Code Camp Lab 1
Optaros Surf Code Camp Lab 1Optaros Surf Code Camp Lab 1
Optaros Surf Code Camp Lab 1
 
Spring Surf 101
Spring Surf 101Spring Surf 101
Spring Surf 101
 
Real-World AJAX with ASP.NET
Real-World AJAX with ASP.NETReal-World AJAX with ASP.NET
Real-World AJAX with ASP.NET
 
T5 Oli Aro
T5 Oli AroT5 Oli Aro
T5 Oli Aro
 
Struts Portlet
Struts PortletStruts Portlet
Struts Portlet
 
Running PHP on a Java container
Running PHP on a Java containerRunning PHP on a Java container
Running PHP on a Java container
 
Ext 0523
Ext 0523Ext 0523
Ext 0523
 
Introduction to Alfresco Surf Platform
Introduction to Alfresco Surf PlatformIntroduction to Alfresco Surf Platform
Introduction to Alfresco Surf Platform
 
Front End Website Optimization
Front End Website OptimizationFront End Website Optimization
Front End Website Optimization
 
New Browsers
New BrowsersNew Browsers
New Browsers
 
An introduction to juice
An introduction to juice An introduction to juice
An introduction to juice
 
How to learn to build your own PHP framework
How to learn to build your own PHP frameworkHow to learn to build your own PHP framework
How to learn to build your own PHP framework
 
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.frameworkHanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
 
Creating Yahoo Mobile Widgets
Creating Yahoo Mobile WidgetsCreating Yahoo Mobile Widgets
Creating Yahoo Mobile Widgets
 
Terracotta Ch'ti Jug
Terracotta Ch'ti JugTerracotta Ch'ti Jug
Terracotta Ch'ti Jug
 
Mobile library on drupal cil2011
Mobile library on drupal   cil2011Mobile library on drupal   cil2011
Mobile library on drupal cil2011
 
EPiServer Web Parts
EPiServer Web PartsEPiServer Web Parts
EPiServer Web Parts
 
Servlet30 20081218
Servlet30 20081218Servlet30 20081218
Servlet30 20081218
 

Mais de Jeff Potts

Alfresco Community Survey 2012 Results
Alfresco Community Survey 2012 ResultsAlfresco Community Survey 2012 Results
Alfresco Community Survey 2012 Results
Jeff Potts
 

Mais de Jeff Potts (20)

No Docker? No Problem: Automating installation and config with Ansible
No Docker? No Problem: Automating installation and config with AnsibleNo Docker? No Problem: Automating installation and config with Ansible
No Docker? No Problem: Automating installation and config with Ansible
 
Moving From Actions & Behaviors to Microservices
Moving From Actions & Behaviors to MicroservicesMoving From Actions & Behaviors to Microservices
Moving From Actions & Behaviors to Microservices
 
Flexible Permissions Management with ACL Templates
Flexible Permissions Management with ACL TemplatesFlexible Permissions Management with ACL Templates
Flexible Permissions Management with ACL Templates
 
Moving Gigantic Files Into and Out of the Alfresco Repository
Moving Gigantic Files Into and Out of the Alfresco RepositoryMoving Gigantic Files Into and Out of the Alfresco Repository
Moving Gigantic Files Into and Out of the Alfresco Repository
 
Could Alfresco Survive a Zombie Attack?
Could Alfresco Survive a Zombie Attack?Could Alfresco Survive a Zombie Attack?
Could Alfresco Survive a Zombie Attack?
 
Connecting Content Management Apps with CMIS
Connecting Content Management Apps with CMISConnecting Content Management Apps with CMIS
Connecting Content Management Apps with CMIS
 
The Challenges of Keeping Bees
The Challenges of Keeping BeesThe Challenges of Keeping Bees
The Challenges of Keeping Bees
 
Getting Started With CMIS
Getting Started With CMISGetting Started With CMIS
Getting Started With CMIS
 
Alfresco: What every developer should know
Alfresco: What every developer should knowAlfresco: What every developer should know
Alfresco: What every developer should know
 
CMIS: An Open API for Managing Content
CMIS: An Open API for Managing ContentCMIS: An Open API for Managing Content
CMIS: An Open API for Managing Content
 
Apache Chemistry in Action: Using CMIS and your favorite language to unlock c...
Apache Chemistry in Action: Using CMIS and your favorite language to unlock c...Apache Chemistry in Action: Using CMIS and your favorite language to unlock c...
Apache Chemistry in Action: Using CMIS and your favorite language to unlock c...
 
Alfresco: The Story of How Open Source Disrupted the ECM Market
Alfresco: The Story of How Open Source Disrupted the ECM MarketAlfresco: The Story of How Open Source Disrupted the ECM Market
Alfresco: The Story of How Open Source Disrupted the ECM Market
 
Join the Alfresco community
Join the Alfresco communityJoin the Alfresco community
Join the Alfresco community
 
Intro to the Alfresco Public API
Intro to the Alfresco Public APIIntro to the Alfresco Public API
Intro to the Alfresco Public API
 
Apache Chemistry in Action
Apache Chemistry in ActionApache Chemistry in Action
Apache Chemistry in Action
 
Building Content-Rich Java Apps in the Cloud with the Alfresco API
Building Content-Rich Java Apps in the Cloud with the Alfresco APIBuilding Content-Rich Java Apps in the Cloud with the Alfresco API
Building Content-Rich Java Apps in the Cloud with the Alfresco API
 
Alfresco Community Survey 2012 Results
Alfresco Community Survey 2012 ResultsAlfresco Community Survey 2012 Results
Alfresco Community Survey 2012 Results
 
Getting Started with CMIS
Getting Started with CMISGetting Started with CMIS
Getting Started with CMIS
 
Relational Won't Cut It: Architecting Content Centric Apps
Relational Won't Cut It: Architecting Content Centric AppsRelational Won't Cut It: Architecting Content Centric Apps
Relational Won't Cut It: Architecting Content Centric Apps
 
Alfresco SAUG: State of ECM
Alfresco SAUG: State of ECMAlfresco SAUG: State of ECM
Alfresco SAUG: State of ECM
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Optaros Surf Code Camp Walkthrough 2

  • 1. Alfresco Surf Code Camp Walkthrough 2: Adding CMIS to Green Energy
  • 2. Objectives Place additional functionality into Green Energy Site Get exposed to CMIS by adding a component that lists the contents of a folder Use E4X to parse XML in JavaScript 07/11/08 2
  • 3. Green Energy We will extend the Green Energy site you started in Lab #3 Sample location: • /opt/tomcat/webapps/alfwf • http://labs3c:8580/alfwf 07/11/08 3
  • 4. Directories Green Energy Web Application • /opt/tomcat/webapps/alfwf site-data • /WEB-INF/classes/alfresco/site-data site-webscripts • /WEB-INF/classes/alfresco/site-webscripts FreeMarker templates • /WEB-INF/classes/alfresco/templates 07/11/08 4
  • 5. Drop in assets Unzip the assets.zip file into the web application Manifest: • /images/age/folder.png • /images/age/page.png • /WEB-INF/classes/alfresco/templates/age/tools.ftl • /WEB-INF/classes/alfresco/site-webscripts/age/feed-util.js 07/11/08 5
  • 6. Add a tools page Add a tools page Points to a rendering template: tools tools.xml /WEB-INF/classes/alfresco/site-data/pages <?xml version='1.0' encoding='UTF-8'?> <page> <title>Tools</title> <template-instance>tools</template-instance> <authentication>user</authentication> </page> The tools page must know how to render • Use template instance: tools 07/11/08 6
  • 7. Add a tools template instance Add a tools template instance Points to a FreeMarker file: /age/tools tools.xml • /WEB-INF/classes/alfresco/site-data/template-instances <?xml version='1.0' encoding='UTF-8'?> <template-instance> <template-type>/age/tools</template-type> </template-instance> The template instance needs a renderer • The FreeMarker renderer: /age/tools.ftl • You already unzipped this. It was in assets.zip 07/11/08 7
  • 8. Tools Template navigation  template scope left content page scope page scope footer  global scope 07/11/08 8
  • 9. Bind in the navigation component Add a component binding for the navigation template.navigation.tools.xml • /WEB-INF/classes/alfresco/site-data/components <?xml version='1.0' encoding='UTF-8'?> <component> <scope>template</scope> <region-id>navigation</region-id> <source-id>tools</source-id> <url>/blocks/navigation</url> </component> Note: The footer will naturally bind as it is globally scoped. 07/11/08 9
  • 10. Add as a child of the home page Adds the ‘tools’ page as a child of the ‘home’ page • Page association home-tools.xml • /WEB-INF/classes/alfresco/site-data/page-associations <?xml version='1.0' encoding='UTF-8'?> <page-association> <source-id>home</source-id> <dest-id>tools</dest-id> <assoc-type>child</assoc-type> </page-association> 07/11/08 10
  • 11. Try it out Start Alfresco • http://labs3c:8080/alfresco Start Surf Tomcat • http://labs3c:8580/alfwf Browse to • http://labs3c:8580/alfwf/service/index Click on ‘Refresh’ to reset the Web Scripts cache Test your site • http://labs3c:8580/alfwf 07/11/08 11
  • 13. Add a FolderList Component Navigate to the site-webscripts directory • /WEB-INF/classes/alfresco/site-webscripts Create a folder called age Navigate into the age directory • /WEB-INF/classes/alfresco/site-webscripts/age Create a Web Script: • folderlist 07/11/08 13
  • 14. FolderList Component Create a web script with the following url • /age/folderlist folderlist.get.desc.xml <webscript> <shortname>Folder Listing</shortname> <description>Provides a list of contents under Company Home</description> <url>/age/folderlist</url> </webscript> 07/11/08 14
  • 15. FolderList Component folderlist.get.properties folderlist.name = Folder Listing 07/11/08 15
  • 16. FolderList Component folderlist.get.js <import resource=quot;classpath:alfresco/site-webscripts/age/feed.utils.jsquot;> // TODO: Load the feed var feed = null; // TODO: convert feed to JavaScript var xml = null; // set up the model model.title = xml.*::title.toString(); var items = new Array(); for each (entry in xml.*::entry) { var item = { }; // TODO: retrieve title value item[quot;titlequot;] = null; // TODO: retrieve icon value item[quot;iconquot;] = null; items.push(item); } model.items = items; 07/11/08 16
  • 17. Notes FolderList Component Loading the feed • Recommended API (CMIS) • /api/path/workspace/SpacesStore/<path>/children • Example: /api/path/workspace/SpacesStore/Company%20Home/children Convert the feed to JavaScript • Helper function defined in import • var xmlObject = loadFeed(feed); • <import resource=quot;classpath:alfresco/site-webscripts/age/feed.utils.jsquot;> Set up the model • Namespace aware • Use namespace independent way of pulling properties • var value = node.*::propertyName.toString(); More info on E4X • http://www.ibm.com/developerworks/library/ws-ajax1/ 07/11/08 17
  • 18. FolderList Component folderlist.get.html.ftl <div> <div class=quot;titlequot;>TODO#1</div> <div class=quot;bodyquot;> <h2>TODO#2</h2> <ul> <#list items as item> <li><img src=“TODO#3quot;/>&nbsp;TODO#4</li> </#list> </ul> </div> </div> 07/11/08 18
  • 19. Notes FolderList Component TODO #1 • Insert value of folderlist.name from properties file • Syntax: ${msg(string)} TODO #2 • Insert value of title from model • Syntax: ${variableName} or ${object.variableName} TODO #3 • Insert value of icon from items array • Syntax: ${variableName} or ${object.variableName} TODO #4 • Insert value of title from items array • Syntax: ${variableName} or ${object.variableName} 07/11/08 19
  • 20. Bind in the FolderList component Add a component binding for the FolderList component page.content.tools.xml • /WEB-INF/classes/alfresco/site-data/components <?xml version='1.0' encoding='UTF-8'?> <component> <scope>page</scope> <region-id>content</region-id> <source-id>tools</source-id> <url>/age/folderlist</url> </component> 07/11/08 20
  • 21. Try it out Start Alfresco • http://labs3c:8080/alfresco Start Surf Tomcat • http://labs3c:8580/alfwf Browse to • http://labs3c:8580/alfwf/service/index Click on ‘Refresh’ to reset the Web Scripts cache Test your site • http://labs3c:8580/alfwf 07/11/08 21
  • 23. Try it out Potential problem: Images not showing up • http://localhost:8080/alfresco/images/xyz.gif • http://labs3c:8580/alfresco/images/xyz.gif • Hack: entry.*::icon.toString().replace('localhost', 'labs3c'); 07/11/08 23
  • 24. Wrap-up In this walkthrough, you... • Added a new page called Tools • Bound a new “folderlist” component to a region on the Tools page • Implemented the folderlist component to use a CMIS call to retrieve the folder contents of a specified path • Used E4X to parse the XML that CMIS returned 07/11/08 Optaros and Client confidential. All rights reserved. 24