SlideShare uma empresa Scribd logo
1 de 22
Baixar para ler offline
APACHE SLING & FRIENDS TECH MEETUP 
BERLIN, 22-24 SEPTEMBER 2014 
Dynamic Components using SPA Concepts 
Andon Sikavica, Bojana Popovska
Dynamic Components 
adaptTo() 2014 2
Dynamic vs Static Components 
Initial and form-based 
components take big chunk 
of the statics 
We spend more than 90% 
of the time developing 
dynamics 
Count of Dynamic vs Statics 
(in hundreds) 
Dynamic Static 
adaptTo() 2014 3
Dynamic Component Development 
 Placeholder for dynamic component in dispatcher 
 think about what you will have in the dispatcher 
 Request dynamic component via URL 
 /content/page/_jcr_content/par/comp.dynamic.html 
 Instruct dispatcher not to cache based on selector 
 #/0042 { /type "deny" /glob "GET *.dynamic.html*" } 
adaptTo() 2014 4
Server Side Includes 
Browser Dispatcher AEM 
GET Page 
return complete Page 
<!--#include virtual= 
“${c.resourcePath}.dynamic.html}”--> 
GET dynamic component HTML 
return component HTML 
with dynamic data 
Generate 
HTML 
adaptTo() 2014 5
AJAX 
Browser Dispatcher AEM 
GET Page 
return Page with 
Placeholders 
GET dynamic component HTML 
$.ajax({ 
url: '${c.resourcePath}.dynamic.html', 
success: function(data) { 
$(“#${c.identifier}").replaceWith(data); 
}}); 
return component HTML 
with dynamic data 
Generate 
HTML 
Create 
Markup 
adaptTo() 2014 6
Summary 
 Sling Concepts 
 component-path 
 selectors 
 sling:resourceSuperType 
 Aspect-Oriented Solution 
 Sling Dynamic Include 
adaptTo() 2014 – https://www.flickr.com/photos/fabrisalvetti/489593502 image by Fabrizio Salvetti 7
What if… 
 … you have high number of dynamic 
components on a single page? 
 … your components need to communicate 
between themselves and update their state? 
 … you need to do notifications for the user? 
…basically need SPA 
adaptTo() 2014 8
Why were the usual approaches Tricky? 
They were meant to be used 
with page reloads 
They work with pre-loaded 
Markup from server 
adaptTo() 2014 - https://www.flickr.com/photos/15708236@N07/2754478731 photo by jphilipg 9
Single Page Application 
adaptTo() 2014 10
SPA Component 
 Rendering Script (JSP) 
 Cached, Inherited 
 Module (JS) 
 Cached, Composition 
 Controller 
 Handles all dynamic calls 
Abstract 
Table 
Paging 
Sorting 
adaptTo() 2014 11
Page Load 
Browser Dispatcher AEM 
GET Page 
return Markup Skeleton 
POST for Dynamic Data 
return Dynamic Data as JSON 
Serialize 
Data as 
JSON 
Render HTML 
using Template 
with dynamic data 
adaptTo() 2014 12
Technologies 
 jQuery 
 jQuery loadTemplate 
 GSON 
 Spring (MVC, AOP) 
adaptTo() 2014 13
Benefits 
 Perceived User Experience 
 Separation of front- and 
back-end engineering 
 easier development 
 prototype 
 mocked data 
adaptTo() 2014 - https://www.flickr.com/photos/mishism/5370473007 photo by Mish Sukharev 14
Showcase 
adaptTo() 2014 15
Rendering Script 
<script type=“text/html” 
id=“scheduleTableTemplate”> 
<tr> 
<td data-content=“talkName”></td> 
<td data-content =“time”></td> 
</tr> 
Static 
Markup 
</table> Template 
</script> 
class=“scheduleTable”> 
<th> 
<td>Talk Name</td> 
<td>Time</td> 
</th> 
<tbody></tbody> 
$(‘.scheduleTable tbody’).loadTemplate( 
$(‘#scheduleTableTemplate’), 
data.talks); 
<table 
<script type=“text/javascript”> 
aemdemo.scheduletable.init( 
‘http://localhost:4502/bin/mvc.do/scheduletable/getresult’); 
</script> 
Inject data 
Initialization script 
adaptTo() 2014 16
Module 
aemdemo.schedulestable = (function($, paging, sort){ 
var params; 
function init (dataUrl){ 
params.dataUrl = dataUrl; 
} 
function getDataByPage (pageNumber) { 
$.ajax { 
data : {. . .}, 
url : params.dataUrl, 
success : function (data){paging.update (data)} 
} 
} 
return { 
init:init 
} 
}(jQuery, aemdemo.paging, aemdemo.sort)); 
adaptTo() 2014 17
Controller 
@Controller 
public class ScheduleTableController { 
@RequestMapping(value = "/scheduletable/getresult", 
produces = {"application/json" }, method = POST) 
@ResponseBody 
public String getResult(@RequestParam int pageNumber) { 
ConferenceDay conferenceDay = getDataFromService(); 
return serializeData(conferenceDay); 
} 
adaptTo() 2014 18 
}
Identify and Control POSTs 
 Add Header 
$.ajaxPrefilter(function (options, originalOptions, jqXHR) { 
jqXHR.setRequestHeader('X-Request-Source', ‘spa-ajax'); 
}); 
 Check Handler 
Servlet servlet = servletResolver.resolveServlet(slingRequest); 
if (“SlingPostServlet”.equals(servlet.getClass().getSimpleName() 
&& isDynamicRequest() ) { 
// ups 
} 
adaptTo() 2014 19
Demo Project 
http://bit.ly/aemspademo 
adaptTo() 2014 20
Questions 
adaptTo() 2014 21
Thank You! 
adaptTo() 2014 22

Mais conteúdo relacionado

Mais procurados

Rest and Sling Resolution
Rest and Sling ResolutionRest and Sling Resolution
Rest and Sling Resolution
DEEPAK KHETAWAT
 
Understanding PostgreSQL LW Locks
Understanding PostgreSQL LW LocksUnderstanding PostgreSQL LW Locks
Understanding PostgreSQL LW Locks
Jignesh Shah
 

Mais procurados (20)

AEM Best Practices for Component Development
AEM Best Practices for Component DevelopmentAEM Best Practices for Component Development
AEM Best Practices for Component Development
 
AEM Rich Text Editor (RTE) Deep Dive
AEM Rich Text Editor (RTE) Deep DiveAEM Rich Text Editor (RTE) Deep Dive
AEM Rich Text Editor (RTE) Deep Dive
 
AEM - Client Libraries
AEM - Client LibrariesAEM - Client Libraries
AEM - Client Libraries
 
AEM (CQ) Dispatcher Security and CDN+Browser Caching
AEM (CQ) Dispatcher Security and CDN+Browser CachingAEM (CQ) Dispatcher Security and CDN+Browser Caching
AEM (CQ) Dispatcher Security and CDN+Browser Caching
 
Sightly - Part 2
Sightly - Part 2Sightly - Part 2
Sightly - Part 2
 
Mastering the Sling Rewriter
Mastering the Sling RewriterMastering the Sling Rewriter
Mastering the Sling Rewriter
 
Introduction to Sightly
Introduction to SightlyIntroduction to Sightly
Introduction to Sightly
 
AEM Sightly Template Language
AEM Sightly Template LanguageAEM Sightly Template Language
AEM Sightly Template Language
 
Aem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricks
 
Sling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak KhetawatSling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak Khetawat
 
AEM GEMs Session Oak Lucene Indexes
AEM GEMs Session Oak Lucene IndexesAEM GEMs Session Oak Lucene Indexes
AEM GEMs Session Oak Lucene Indexes
 
Rest and Sling Resolution
Rest and Sling ResolutionRest and Sling Resolution
Rest and Sling Resolution
 
Elastic search adaptto2014
Elastic search adaptto2014Elastic search adaptto2014
Elastic search adaptto2014
 
MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and Concepts
 
Adobe Experience Manager Core Components
Adobe Experience Manager Core ComponentsAdobe Experience Manager Core Components
Adobe Experience Manager Core Components
 
JCR, Sling or AEM? Which API should I use and when?
JCR, Sling or AEM? Which API should I use and when?JCR, Sling or AEM? Which API should I use and when?
JCR, Sling or AEM? Which API should I use and when?
 
Java Spring
Java SpringJava Spring
Java Spring
 
Spring Data JPA
Spring Data JPASpring Data JPA
Spring Data JPA
 
Spring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsSpring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topics
 
Understanding PostgreSQL LW Locks
Understanding PostgreSQL LW LocksUnderstanding PostgreSQL LW Locks
Understanding PostgreSQL LW Locks
 

Destaque

Build single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMBuild single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEM
connectwebex
 
Microservices Architecture for AEM
Microservices Architecture for AEMMicroservices Architecture for AEM
Microservices Architecture for AEM
Maciej Majchrzak
 
Four approaches to integrate aem with external systems by Jan Kuzniak
Four approaches to integrate aem with external systems by Jan KuzniakFour approaches to integrate aem with external systems by Jan Kuzniak
Four approaches to integrate aem with external systems by Jan Kuzniak
AEM HUB
 
Stacking the Odds for Authentic Growth
Stacking the Odds for Authentic GrowthStacking the Odds for Authentic Growth
Stacking the Odds for Authentic Growth
Sean Ellis
 

Destaque (20)

Dynamic components using SPA concepts in AEM
Dynamic components using SPA concepts in AEMDynamic components using SPA concepts in AEM
Dynamic components using SPA concepts in AEM
 
Bridging the Gap: Single-Page Apps and AEM
Bridging the Gap: Single-Page Apps and AEMBridging the Gap: Single-Page Apps and AEM
Bridging the Gap: Single-Page Apps and AEM
 
Build single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMBuild single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEM
 
Sling Dynamic Include
Sling Dynamic IncludeSling Dynamic Include
Sling Dynamic Include
 
EVOLVE'16 | Enhance | Paul McMahon | Approaches to Leveraging AEM Within a Si...
EVOLVE'16 | Enhance | Paul McMahon | Approaches to Leveraging AEM Within a Si...EVOLVE'16 | Enhance | Paul McMahon | Approaches to Leveraging AEM Within a Si...
EVOLVE'16 | Enhance | Paul McMahon | Approaches to Leveraging AEM Within a Si...
 
Cqcon2015
Cqcon2015Cqcon2015
Cqcon2015
 
Build single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMBuild single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEM
 
CRX2Oak - all the secrets of repository migration
CRX2Oak - all the secrets of repository migrationCRX2Oak - all the secrets of repository migration
CRX2Oak - all the secrets of repository migration
 
content modelling for personalization
content modelling for personalizationcontent modelling for personalization
content modelling for personalization
 
[143]Inside fuse deview 2016
[143]Inside fuse   deview 2016[143]Inside fuse   deview 2016
[143]Inside fuse deview 2016
 
Creating Real-Time Data Mashups with Node.JS and Adobe CQ
Creating Real-Time Data Mashups with Node.JS and Adobe CQCreating Real-Time Data Mashups with Node.JS and Adobe CQ
Creating Real-Time Data Mashups with Node.JS and Adobe CQ
 
REST in AEM
REST in AEMREST in AEM
REST in AEM
 
The six key steps to AEM architecture
The six key steps to AEM architectureThe six key steps to AEM architecture
The six key steps to AEM architecture
 
Adobe Meetup AEM Architecture Sydney 2015
Adobe Meetup AEM Architecture Sydney 2015Adobe Meetup AEM Architecture Sydney 2015
Adobe Meetup AEM Architecture Sydney 2015
 
Microservices Architecture for AEM
Microservices Architecture for AEMMicroservices Architecture for AEM
Microservices Architecture for AEM
 
Four approaches to integrate aem with external systems by Jan Kuzniak
Four approaches to integrate aem with external systems by Jan KuzniakFour approaches to integrate aem with external systems by Jan Kuzniak
Four approaches to integrate aem with external systems by Jan Kuzniak
 
Stacking the Odds for Authentic Growth
Stacking the Odds for Authentic GrowthStacking the Odds for Authentic Growth
Stacking the Odds for Authentic Growth
 
Setting and Achieving Growth Goals
Setting and Achieving Growth GoalsSetting and Achieving Growth Goals
Setting and Achieving Growth Goals
 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8
 
Developing an Intranet Strategy
Developing an Intranet StrategyDeveloping an Intranet Strategy
Developing an Intranet Strategy
 

Semelhante a Dynamic Components using Single-Page-Application Concepts in AEM/CQ

Semelhante a Dynamic Components using Single-Page-Application Concepts in AEM/CQ (20)

Presentation Tier optimizations
Presentation Tier optimizationsPresentation Tier optimizations
Presentation Tier optimizations
 
Maciej Treder ''Angular Universal - a medicine for the Angular + SEO/CDN issu...
Maciej Treder ''Angular Universal - a medicine for the Angular + SEO/CDN issu...Maciej Treder ''Angular Universal - a medicine for the Angular + SEO/CDN issu...
Maciej Treder ''Angular Universal - a medicine for the Angular + SEO/CDN issu...
 
Getting started with hot towel spa
Getting started with hot towel spaGetting started with hot towel spa
Getting started with hot towel spa
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics
 
OttawaJS - React
OttawaJS - ReactOttawaJS - React
OttawaJS - React
 
WordCamp Montreal 2016 WP-API + React with server rendering
WordCamp Montreal 2016  WP-API + React with server renderingWordCamp Montreal 2016  WP-API + React with server rendering
WordCamp Montreal 2016 WP-API + React with server rendering
 
Monitoring web application response times, a new approach
Monitoring web application response times, a new approachMonitoring web application response times, a new approach
Monitoring web application response times, a new approach
 
Best practices in using Salesforce Metadata API
Best practices in using Salesforce Metadata APIBest practices in using Salesforce Metadata API
Best practices in using Salesforce Metadata API
 
Get your mobile app in production in 3 months: Native and Reactive Mobile Apps
Get your mobile app in production in 3 months: Native and Reactive Mobile AppsGet your mobile app in production in 3 months: Native and Reactive Mobile Apps
Get your mobile app in production in 3 months: Native and Reactive Mobile Apps
 
Spring-training-in-bangalore
Spring-training-in-bangaloreSpring-training-in-bangalore
Spring-training-in-bangalore
 
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
 
Asp.net By Durgesh Singh
Asp.net By Durgesh SinghAsp.net By Durgesh Singh
Asp.net By Durgesh Singh
 
Rethinking Angular Architecture & Performance
Rethinking Angular Architecture & PerformanceRethinking Angular Architecture & Performance
Rethinking Angular Architecture & Performance
 
Best practices in using Salesforce Metadata API
Best practices in using Salesforce Metadata APIBest practices in using Salesforce Metadata API
Best practices in using Salesforce Metadata API
 
Building Single Page Application (SPA) with Symfony2 and AngularJS
Building Single Page Application (SPA) with Symfony2 and AngularJSBuilding Single Page Application (SPA) with Symfony2 and AngularJS
Building Single Page Application (SPA) with Symfony2 and AngularJS
 
Presemtation Tier Optimizations
Presemtation Tier OptimizationsPresemtation Tier Optimizations
Presemtation Tier Optimizations
 
Bringing the JAMstack to the Enterprise
Bringing the JAMstack to the EnterpriseBringing the JAMstack to the Enterprise
Bringing the JAMstack to the Enterprise
 
Achievement Archive
Achievement ArchiveAchievement Archive
Achievement Archive
 
Modular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSModular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJS
 
Divide et impera
Divide et imperaDivide et impera
Divide et impera
 

Mais de Netcetera

Mais de Netcetera (20)

Payment trend scouting - Kurt Schmid, Netcetera
Payment trend scouting - Kurt Schmid, NetceteraPayment trend scouting - Kurt Schmid, Netcetera
Payment trend scouting - Kurt Schmid, Netcetera
 
Boost your approved transaction volume - Ana Vuksanovikj Vaneska, Netcetera
Boost your approved transaction volume - Ana Vuksanovikj Vaneska, NetceteraBoost your approved transaction volume - Ana Vuksanovikj Vaneska, Netcetera
Boost your approved transaction volume - Ana Vuksanovikj Vaneska, Netcetera
 
Increase conversion, convenience and security in e-commerce checkouts - Silke...
Increase conversion, convenience and security in e-commerce checkouts - Silke...Increase conversion, convenience and security in e-commerce checkouts - Silke...
Increase conversion, convenience and security in e-commerce checkouts - Silke...
 
3-D Secure 2.0 - Stephan Rüdisüli, Netcetera & Patrick Juffern, INFORM
3-D Secure 2.0 - Stephan Rüdisüli, Netcetera & Patrick Juffern, INFORM3-D Secure 2.0 - Stephan Rüdisüli, Netcetera & Patrick Juffern, INFORM
3-D Secure 2.0 - Stephan Rüdisüli, Netcetera & Patrick Juffern, INFORM
 
Digital Payment in 2020 - Kurt Schmid, Netcetera
Digital Payment in 2020 - Kurt Schmid, NetceteraDigital Payment in 2020 - Kurt Schmid, Netcetera
Digital Payment in 2020 - Kurt Schmid, Netcetera
 
AI First. Erfolgsfaktoren für künstliche Intelligenz im Unternehmen
AI First. Erfolgsfaktoren für künstliche Intelligenz im UnternehmenAI First. Erfolgsfaktoren für künstliche Intelligenz im Unternehmen
AI First. Erfolgsfaktoren für künstliche Intelligenz im Unternehmen
 
Augmenting Maintenance
Augmenting MaintenanceAugmenting Maintenance
Augmenting Maintenance
 
Front-end up front
Front-end up frontFront-end up front
Front-end up front
 
The future of Prototpying
The future of PrototpyingThe future of Prototpying
The future of Prototpying
 
EMV Secure Remote Commerce (SRC)
EMV Secure Remote Commerce (SRC)EMV Secure Remote Commerce (SRC)
EMV Secure Remote Commerce (SRC)
 
Online shopping technology in the fast lane?
Online shopping technology in the fast lane?Online shopping technology in the fast lane?
Online shopping technology in the fast lane?
 
Merchant tokenization and EMV® Secure Remote Commerce
Merchant tokenization and EMV® Secure Remote CommerceMerchant tokenization and EMV® Secure Remote Commerce
Merchant tokenization and EMV® Secure Remote Commerce
 
Seamless 3-D Secure e-commerce experience
Seamless 3-D Secure e-commerce experienceSeamless 3-D Secure e-commerce experience
Seamless 3-D Secure e-commerce experience
 
Augmenting Health Care
Augmenting Health CareAugmenting Health Care
Augmenting Health Care
 
Driving transactional growth with 3-D Secure
Driving transactional growth with 3-D SecureDriving transactional growth with 3-D Secure
Driving transactional growth with 3-D Secure
 
Digital Payment Quo Vadis
Digital Payment Quo VadisDigital Payment Quo Vadis
Digital Payment Quo Vadis
 
EMV® Secure Remote Commerce
EMV® Secure Remote CommerceEMV® Secure Remote Commerce
EMV® Secure Remote Commerce
 
Context: The missing ingredient in multilingual software translation
Context: The missing ingredient in multilingual software translationContext: The missing ingredient in multilingual software translation
Context: The missing ingredient in multilingual software translation
 
Digital Payments - Netcetera Innovation Summit 2018
Digital Payments - Netcetera Innovation Summit 2018Digital Payments - Netcetera Innovation Summit 2018
Digital Payments - Netcetera Innovation Summit 2018
 
"Whats up and new at Netcetera?" - Netcetera Innovation Summit 2018
"Whats up and new at Netcetera?" - Netcetera Innovation Summit 2018"Whats up and new at Netcetera?" - Netcetera Innovation Summit 2018
"Whats up and new at Netcetera?" - Netcetera Innovation Summit 2018
 

Último

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 

Último (20)

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 

Dynamic Components using Single-Page-Application Concepts in AEM/CQ

  • 1. APACHE SLING & FRIENDS TECH MEETUP BERLIN, 22-24 SEPTEMBER 2014 Dynamic Components using SPA Concepts Andon Sikavica, Bojana Popovska
  • 3. Dynamic vs Static Components Initial and form-based components take big chunk of the statics We spend more than 90% of the time developing dynamics Count of Dynamic vs Statics (in hundreds) Dynamic Static adaptTo() 2014 3
  • 4. Dynamic Component Development  Placeholder for dynamic component in dispatcher  think about what you will have in the dispatcher  Request dynamic component via URL  /content/page/_jcr_content/par/comp.dynamic.html  Instruct dispatcher not to cache based on selector  #/0042 { /type "deny" /glob "GET *.dynamic.html*" } adaptTo() 2014 4
  • 5. Server Side Includes Browser Dispatcher AEM GET Page return complete Page <!--#include virtual= “${c.resourcePath}.dynamic.html}”--> GET dynamic component HTML return component HTML with dynamic data Generate HTML adaptTo() 2014 5
  • 6. AJAX Browser Dispatcher AEM GET Page return Page with Placeholders GET dynamic component HTML $.ajax({ url: '${c.resourcePath}.dynamic.html', success: function(data) { $(“#${c.identifier}").replaceWith(data); }}); return component HTML with dynamic data Generate HTML Create Markup adaptTo() 2014 6
  • 7. Summary  Sling Concepts  component-path  selectors  sling:resourceSuperType  Aspect-Oriented Solution  Sling Dynamic Include adaptTo() 2014 – https://www.flickr.com/photos/fabrisalvetti/489593502 image by Fabrizio Salvetti 7
  • 8. What if…  … you have high number of dynamic components on a single page?  … your components need to communicate between themselves and update their state?  … you need to do notifications for the user? …basically need SPA adaptTo() 2014 8
  • 9. Why were the usual approaches Tricky? They were meant to be used with page reloads They work with pre-loaded Markup from server adaptTo() 2014 - https://www.flickr.com/photos/15708236@N07/2754478731 photo by jphilipg 9
  • 10. Single Page Application adaptTo() 2014 10
  • 11. SPA Component  Rendering Script (JSP)  Cached, Inherited  Module (JS)  Cached, Composition  Controller  Handles all dynamic calls Abstract Table Paging Sorting adaptTo() 2014 11
  • 12. Page Load Browser Dispatcher AEM GET Page return Markup Skeleton POST for Dynamic Data return Dynamic Data as JSON Serialize Data as JSON Render HTML using Template with dynamic data adaptTo() 2014 12
  • 13. Technologies  jQuery  jQuery loadTemplate  GSON  Spring (MVC, AOP) adaptTo() 2014 13
  • 14. Benefits  Perceived User Experience  Separation of front- and back-end engineering  easier development  prototype  mocked data adaptTo() 2014 - https://www.flickr.com/photos/mishism/5370473007 photo by Mish Sukharev 14
  • 16. Rendering Script <script type=“text/html” id=“scheduleTableTemplate”> <tr> <td data-content=“talkName”></td> <td data-content =“time”></td> </tr> Static Markup </table> Template </script> class=“scheduleTable”> <th> <td>Talk Name</td> <td>Time</td> </th> <tbody></tbody> $(‘.scheduleTable tbody’).loadTemplate( $(‘#scheduleTableTemplate’), data.talks); <table <script type=“text/javascript”> aemdemo.scheduletable.init( ‘http://localhost:4502/bin/mvc.do/scheduletable/getresult’); </script> Inject data Initialization script adaptTo() 2014 16
  • 17. Module aemdemo.schedulestable = (function($, paging, sort){ var params; function init (dataUrl){ params.dataUrl = dataUrl; } function getDataByPage (pageNumber) { $.ajax { data : {. . .}, url : params.dataUrl, success : function (data){paging.update (data)} } } return { init:init } }(jQuery, aemdemo.paging, aemdemo.sort)); adaptTo() 2014 17
  • 18. Controller @Controller public class ScheduleTableController { @RequestMapping(value = "/scheduletable/getresult", produces = {"application/json" }, method = POST) @ResponseBody public String getResult(@RequestParam int pageNumber) { ConferenceDay conferenceDay = getDataFromService(); return serializeData(conferenceDay); } adaptTo() 2014 18 }
  • 19. Identify and Control POSTs  Add Header $.ajaxPrefilter(function (options, originalOptions, jqXHR) { jqXHR.setRequestHeader('X-Request-Source', ‘spa-ajax'); });  Check Handler Servlet servlet = servletResolver.resolveServlet(slingRequest); if (“SlingPostServlet”.equals(servlet.getClass().getSimpleName() && isDynamicRequest() ) { // ups } adaptTo() 2014 19