Optaros Surf Code Camp Dispatcher
Upcoming SlideShare
Loading in...5
×
 

Optaros Surf Code Camp Dispatcher

on

  • 3,642 views

Learn how to assemble a Surf-based web site. Talks about page dispatching and page assembly.

Learn how to assemble a Surf-based web site. Talks about page dispatching and page assembly.

Statistics

Views

Total Views
3,642
Views on SlideShare
3,633
Embed Views
9

Actions

Likes
0
Downloads
149
Comments
0

3 Embeds 9

http://www.slideshare.net 6
http://www.linkedin.com 2
https://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Optaros Surf Code Camp Dispatcher Optaros Surf Code Camp Dispatcher Presentation Transcript

  • Alfresco Surf Code Camp Dispatcher and Site Construction
  • Objectives By the end of this module you should know • How pages are dispatched • How pages are assembled by invoking component renderers • How Page Types & Themes work together 12/12/08 Optaros and Client confidential. All rights reserved. 2
  • Site Dispatcher You've used web script-based components as Share Dashlets Now let's learn about how Surf sites and Surf pages are built 12/12/08 3
  • Site Dispatcher The site dispatcher is responsible for figuring out which page should be assembled for a given request, and then assembling the page by invoking renderers Page Renderer Renderer Renderer Renderer 12/12/08 4
  • Model Objects Model Objects contain information about site construction A web site looks to these objects during render They define pages and page layout They define where components appear on pages 12/12/08 5
  • Model Objects Model Objects are XML files Here is an example of a component XML file <?xml version='1.0' encoding='UTF-8'?> <component> <scope>global</scope> <region-id>footer</region-id> <source-id>global</source-id> <url>/age/footer</url> <properties> <custom1>My custom property value</custom1> </properties> </component> 12/12/08 6
  • List of Model Objects Types Associations Component Type Page • Association Template Type Content • Page Type Association Instances Site Component Configuration • • Template Theme • • Instance Chrome • Page • 12/12/08 7
  • Key Surf Page Construction Concepts SomeTemplate.ftl Pages Home Header Blog About Gutter Body Template Instances & Regions Renderers Footer Component (Web Script) 12/12/08 Optaros and Client confidential. All rights reserved. 8
  • Model Objects Graph Page Page Page Type Association Template Template Content Type Instance Association Component Component Chrome Type Configuration Theme 12/12/08 9
  • Dispatching Regardless of the path, it always comes down to a Page • An Object is requested -> What page should display it? • A Page Type is requested -> Which page is appropriate for this Theme? • A specific Page is requested URI Resolves to a page Servlet Page Type Requests To Rendering Dispatcher Page Servlet Object Resolves to a page 12/12/08 10
  • Page Dispatching Logic 1. Example: Hitting the home page http://labs3c:8580/alfwf/page?p=home  2. Look up Page (in /site-data/pages)‫‏‬ Page has a template instance.  3. Look up Template Instance (in /site-data/template- instances)‫‏‬ 4. Look up Renderer for Template In this case the Renderer is a FreeMarker Template  Process regions on page by id  5. Find Component Bindings for those region ids 6. Look up Components (in /site-data/components)‫‏‬ 12/12/08 11
  • Page Dispatching Logic Look up the page object by page id: home • /WEB-INF/classes/alfresco/site-data/pages <?xml version='1.0' encoding='UTF-8'?> <page> <title>Home Page</title> <template-instance>home</template-instance> <authentication>none</authentication> </page> Look up the template by template id: home • /WEB-INF/classes/alfresco/site-data/template-instances <?xml version='1.0' encoding='UTF-8'?> <template-instance> <template-type>freemarker</template-type> <url>/sample/home</url> </template-instance> OR Potentially <?xml version='1.0' encoding='UTF-8'?> confusing <template-instance> shortcut here! <template-type>/sample/home</template-type> </template-instance> 12/12/08 12
  • Page Dispatching Logic Execute the Template Renderer for path: /sample/home • FreeMarker renderer • /WEB-INF/classes/alfresco/templates/sample/home.ftl <html> <body> <@region id=“SomeImage” scope=“page” /> </body> </html> Execute the region tag and find matching components • /WEB-INF/classes/alfresco/site-data/components • Search for components in page scope, bound to home page for the region ‘SomeImage’ Components have a naming • page.test.home.xml convention which is duplicative of the XML it contains. Currently, the XML page, scope, and region XML are ignored, but in the future, the naming convention will be dropped. 12/12/08 13
  • Page Dispatching Logic Analyze the Component and prepare to render it • /WEB-INF/classes/alfresco/site-data/components <?xml version='1.0' encoding='UTF-8'?> <component> <scope>page</scope> <region-id>SomeImage</region-id> <source-id>home</source-id> <url>/blocks/image</url> <properties> <src>${url.context}/images/masay.jpg</src> </properties> </component> The url maps to a web script • URL = /blocks/image The properties of the component are fed into the Web Script 12/12/08 14
  • Page Dispatching Logic blocks/image is an Image Display component The Presentation Web Script fetches data from component instance var src = instance.properties[“src”]; if(src != null)‫‏‬ { // proceed } The FreeMarker based view then renders the output <img src=“${src}” /> 12/12/08 15
  • Page Dispatching Logic http://labs3c:8580/alfwf/page?p=home The template would execute home.ftl SomeImage 12/12/08 16
  • Page Dispatching Logic http://labs3c:8580/alfwf/page?p=home Generated output 12/12/08 17
  • Page Type Dispatching Logic Page Types are used to define a general “class” or type of pages Examples: • Login • Profile • Others? Example: Hitting the login page • http://labs3c:8580/alfwf/page?pt=login 12/12/08 18
  • Page Type Dispatching Logic First, see if there is a configured theme Themes can specify overrides for page types ● Default themes are specified by site configuration objects ● <?xml version='1.0' encoding='UTF-8'?> <theme> <title>Extranet - Enterprise Theme</title> <page-types> <page-type> <id>login</id> <page-instance-id>sample-login</page-instance-id> </page-type> </page-types> </theme> 12/12/08 19
  • Page Type Dispatching Logic If nothing specifed in a theme, see if the framework has a default • The web-framework-config*.xml files can specify defaults <alfresco-config> <config evaluator=quot;string-comparequot; condition=quot;WebFrameworkquot;> <web-framework> <application-defaults> <theme>newtheme</theme> <page-type> <id>login</id> <page-instance-id>sample-login</page-instance-id> </page-type> </application-defaults> </web-framework> </config> </alfresco-config> 12/12/08 20
  • Page Type Dispatching Logic Last resort, try to use a generic page • Looks for a page with id = generic 12/12/08 21
  • Page Type Dispatching Logic At this point, we have a page object Dispatch to page as before 12/12/08 22
  • Object Dispatching Logic Example: Displaying a content object http://labs3c:8580/alfwf/page? o=workspace://SpacesStore/56923743-7436-482e-b1cf- eda326d11dc2 • Assumes the default endpoint • “Load content object with this id from the default endpoint” http://labs3c:8580/alfwf/page? o=workspace://SpacesStore/56923743-7436-482e-b1cf- eda326d11dc2&endpointId=alfresco • Uses a specific endpoint • “Load content object with this id from the alfresco endpoint” 12/12/08 23
  • Object Dispatching Logic Look up the ContentLoader implementation • A content loader that knows how to load content from this endpoint <alfresco-config> <config evaluator=quot;string-comparequot; condition=quot;WebFrameworkquot;> <web-framework> <content-loader> <id>alfresco</id> <name>Alfresco Content Loader</name> <class>org.alfresco.web.site.AlfrescoContentLoader</class> <endpoint>alfresco</endpoint> </content-loader> </web-framework> </config> </alfresco-config> 12/12/08 24
  • Object Dispatching Logic If a ContentLoader is found, then load the object Then, look for Content Association instances which describe a match for this content object • /WEB-INF/classes/alfresco/site-data/content-associations <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?> <content-association> <source-id>{http://www.alfresco.org/model/content/1.0}content</source-id> <dest-id>content-details</dest-id> <assoc-type>page</assoc-type> </content-association> Describes a page that can be used to display content of type: {http://www.alfresco.org/model/content/1.0}content 12/12/08 25
  • Object Dispatching Logic At this point, we have a page object Dispatch to page as before 12/12/08 26
  • Site Data /WEB-INF/classes/alfresco /site-data /chrome /components /component-types /configurations /content-associations /page-associations /pages /page-types /template-instances /template-types /themes 12/12/08 27
  • Components /WEB-INF/classes/alfresco /site-webscripts /example /component.get.desc.xml /component.get.js /component.get.html.ftl /component.get.head.ftl /component.get.properties /component.get.config 12/12/08 28
  • Templates /WEB-INF/classes/alfresco /templates /example /template.js /template.ftl /template.head.ftl 12/12/08 29
  • Wrap-up In this module, you learned... • How Surf model objects inter-relate • Three ways pages are dispatched – Specific page – Page type – Object • Pages are assembled by invoking component renderers 12/12/08 Optaros and Client confidential. All rights reserved. 30