SlideShare a Scribd company logo
1 of 16
RESPEKT
QUALITÄT
#EurostaffConnect
mit
FRANK CAPUTO
#EurostaffConnect
mit
Frank Caputo &
Manuel Amoabeng
Modern Websites with JSF
and jQuery
presented by Frank Caputo
and Manuel Amoabeng
The speakers
• Frank Caputo
Freelance Software Architect, JSF EG Member, Author of
JSF Resource Library Contracts, Passthrough Elements
frankcaputo.de
• Manuel Amoabeng
Softwarearchitect and interim PO at dreamIT in Ottensen
dreamit.de
The scenario
• Simple website, which must be crawled by bots
• Users want AJAX
• We must dynamically toggle content
• We must scale over multiple servers
Why JavaServerFaces
• Standard Java Web Framework
• Mature
• Designed for extensibility
• AJAX built in
• Continued development
• Many developers available
• Scalable
Why jQuery
• Mature
• De Facto Standard JavaScript Framework
• Designed for extensibility
• AJAX built in
• Continued development
• Many developers available
Implementation Notes
JSF Stateless Mode
• Disables JSF state saving
• Every form element needs
an ID
• Session must be restorable on any cluster node
• Still use session affinity
<f:view transient="true">
…
</f:view>
JSF AJAX Navigation
jsf.ajax.navigate = function (url) {
var fakeElement = {
form: {action: url, elements: [],
length: 0}
};
var fakeEvent = { type: 'navigate' };
this.request(fakeElement, fakeEvent,
{execute: '@none', render: 'main'});
};
jQuery Click Handlers
$('header nav a').on('click', function (e) {
jsf.ajax.navigate(e.currentTarget.href);
e.preventDefault();
});
JSF AJAX Events
jsf.ajax.addOnEvent(function (data) {
if (data.status == 'success' &&
data.responseCode == 200) {
var x = $(data.responseXML);
x.find('update').each(function (i, e) {
e = document.getElementById(e.id);
$(e).trigger('jsf:ajaxUpdate');
});
}
});
Browser Location Bar
$(document).on('jsf:ajaxUpdate', '#main',
function (e) {
var element = $(e.currentTarget);
var url = element.data('url');
var pathname = window.location.pathname;
if (pathname != url) {
window.history.pushState(null, null, url);
}
$(window).trigger('page:change');
});
Browser Back Button
$(window).on('popstate', function () {
jsf.ajax.navigate(location.pathname);
});
JSF Serverside AJAX Navigation
public class MyPartialViewContext extends
PartialViewContextWrapper {
@Override
public void setRenderAll(boolean renderAll) {
if(renderAll) {
getRenderIds().clear();
getRenderIds().add("main");
}
}
}
DEMO
Thank You!
Q&A
github.com/fcaputo/ModernJSF

More Related Content

What's hot

What's hot (20)

Mvvm is like born fraction
Mvvm is like born fractionMvvm is like born fraction
Mvvm is like born fraction
 
Desktop Bridge with WPF - One way to build modern apps with WPF
Desktop Bridge with WPF - One way to build modern apps with WPFDesktop Bridge with WPF - One way to build modern apps with WPF
Desktop Bridge with WPF - One way to build modern apps with WPF
 
Scaffolding in One Asp.Net
Scaffolding in One Asp.NetScaffolding in One Asp.Net
Scaffolding in One Asp.Net
 
An Introduction to CoffeeScript
An Introduction to CoffeeScriptAn Introduction to CoffeeScript
An Introduction to CoffeeScript
 
Isomorphic javascript - Uppsala.js #8
Isomorphic javascript - Uppsala.js #8Isomorphic javascript - Uppsala.js #8
Isomorphic javascript - Uppsala.js #8
 
Kendo UI Wrappers in ASP.NET Core
Kendo UI Wrappers in ASP.NET CoreKendo UI Wrappers in ASP.NET Core
Kendo UI Wrappers in ASP.NET Core
 
The WP Engine Developer Experience. Increased agility, improved efficiency.
The WP Engine Developer Experience. Increased agility, improved efficiency.The WP Engine Developer Experience. Increased agility, improved efficiency.
The WP Engine Developer Experience. Increased agility, improved efficiency.
 
Node @ flipkart
Node @ flipkartNode @ flipkart
Node @ flipkart
 
Developing JavaScript Widgets
Developing JavaScript WidgetsDeveloping JavaScript Widgets
Developing JavaScript Widgets
 
The Fast Track to Mastering Modern WordPress - Rob Stinson & Carrie Dils
The Fast Track to Mastering Modern WordPress - Rob Stinson & Carrie DilsThe Fast Track to Mastering Modern WordPress - Rob Stinson & Carrie Dils
The Fast Track to Mastering Modern WordPress - Rob Stinson & Carrie Dils
 
Configuration Management Tools
Configuration Management ToolsConfiguration Management Tools
Configuration Management Tools
 
Introducing Rack
Introducing RackIntroducing Rack
Introducing Rack
 
WordPress Multilingual: WordCamp Antwerp 2016
WordPress Multilingual: WordCamp Antwerp 2016WordPress Multilingual: WordCamp Antwerp 2016
WordPress Multilingual: WordCamp Antwerp 2016
 
Developing ASP.NET MVC Applications Quicker With Kendo UI
Developing ASP.NET MVC Applications Quicker With Kendo UIDeveloping ASP.NET MVC Applications Quicker With Kendo UI
Developing ASP.NET MVC Applications Quicker With Kendo UI
 
Php
PhpPhp
Php
 
Knockout
KnockoutKnockout
Knockout
 
Features: A better way to package stuff in Drupal
Features: A better way to package stuff in DrupalFeatures: A better way to package stuff in Drupal
Features: A better way to package stuff in Drupal
 
Next Generation Web Development Techniques with Cloud Foundry
Next Generation Web Development Techniques with Cloud FoundryNext Generation Web Development Techniques with Cloud Foundry
Next Generation Web Development Techniques with Cloud Foundry
 
Aspect oriented programming
Aspect oriented programmingAspect oriented programming
Aspect oriented programming
 
How to build a Mobile API or HTML 5 app in 5 minutes
How to build a Mobile API or HTML 5 app in 5 minutesHow to build a Mobile API or HTML 5 app in 5 minutes
How to build a Mobile API or HTML 5 app in 5 minutes
 

Similar to Modern WebSites with JSF and jQuery

WebNetConf 2012 - Single Page Apps
WebNetConf 2012 - Single Page AppsWebNetConf 2012 - Single Page Apps
WebNetConf 2012 - Single Page Apps
Pop Apps
 

Similar to Modern WebSites with JSF and jQuery (20)

Integrating Alfresco with Portals
Integrating Alfresco with PortalsIntegrating Alfresco with Portals
Integrating Alfresco with Portals
 
Java EE 7 Soup to Nuts at JavaOne 2014
Java EE 7 Soup to Nuts at JavaOne 2014Java EE 7 Soup to Nuts at JavaOne 2014
Java EE 7 Soup to Nuts at JavaOne 2014
 
Modern Web Framework : Play framework
Modern Web Framework : Play frameworkModern Web Framework : Play framework
Modern Web Framework : Play framework
 
WebNetConf 2012 - Single Page Apps
WebNetConf 2012 - Single Page AppsWebNetConf 2012 - Single Page Apps
WebNetConf 2012 - Single Page Apps
 
JSF 2: Myth of panacea? Magic world of user interfaces
JSF 2: Myth of panacea? Magic world of user interfacesJSF 2: Myth of panacea? Magic world of user interfaces
JSF 2: Myth of panacea? Magic world of user interfaces
 
Utilizing JSF Front Ends with Microservices
Utilizing JSF Front Ends with MicroservicesUtilizing JSF Front Ends with Microservices
Utilizing JSF Front Ends with Microservices
 
Implementing portlets using Web Scripts
Implementing portlets using Web ScriptsImplementing portlets using Web Scripts
Implementing portlets using Web Scripts
 
PLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring SurfPLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring Surf
 
Decoupled Architecture and WordPress
Decoupled Architecture and WordPressDecoupled Architecture and WordPress
Decoupled Architecture and WordPress
 
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo
 
Infinum android talks_10_android_libraries_used_on_daily_basis
Infinum android talks_10_android_libraries_used_on_daily_basisInfinum android talks_10_android_libraries_used_on_daily_basis
Infinum android talks_10_android_libraries_used_on_daily_basis
 
ClueCon 2017
ClueCon 2017ClueCon 2017
ClueCon 2017
 
Going mobile with RichFaces
Going mobile with RichFacesGoing mobile with RichFaces
Going mobile with RichFaces
 
Java fx an introduction
Java fx an introductionJava fx an introduction
Java fx an introduction
 
Firefox OS Weekend
Firefox OS WeekendFirefox OS Weekend
Firefox OS Weekend
 
Full stack development using javascript what and why - ajay chandravadiya
Full stack development using javascript   what and why - ajay chandravadiyaFull stack development using javascript   what and why - ajay chandravadiya
Full stack development using javascript what and why - ajay chandravadiya
 
AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project 
 
Javascript 01 (js)
Javascript 01 (js)Javascript 01 (js)
Javascript 01 (js)
 
ITT Flisol 2013
ITT Flisol 2013ITT Flisol 2013
ITT Flisol 2013
 
An evening with React Native
An evening with React NativeAn evening with React Native
An evening with React Native
 

Recently uploaded

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

Recently uploaded (20)

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 

Modern WebSites with JSF and jQuery

Editor's Notes

  1. Vorstellung
  2. Manuel Einfache eCommerce-Seite Im Shopping Cart wird alles verwirrende ausgeblendet Wir wollen Continous Delivery (keine Zeit Sessions ausidlen zu lassen)
  3. Teil des Java EE Standards Existiert seit März 2004 Es gibt für alles Factories, die man dekorieren kann Seit 2.0 Facelets enthalten, AJAX ständige Weiterentwicklung wie z.B. Resource Library Contracts und Passthrough Elements seit 2.2 gibt es den stateless mode
  4. Existiert seit August 2006 hat überlebt jeden Monat eine neue Sau durchs Dorf in der JS-Welt ständige Weiterentwicklung
  5. JSF speichert normalerweise ganz viel in der Session State saving bietet autogenerierte IDs Die Session muss aus irgendeinem Cookie != JSESSIONID wiederherstellbar sein Nutzt weiterhin Sessionaffinity, um zu viel Last auf der DB zu vermeiden
  6. JSF braucht normalerweise ein Formular Dank der Dynamik von JS können wir ein Formular faken Serverseiting guckt JSF nur nach javax.faces.partial.ajax:true wir rendern das Element mit der ID „main“
  7. Alle Navilinks rufen nun jsf.ajax.navigate und unterdrücken das default Verhalten
  8. Man kann sich global an JSF AJAX events hängen „success“ kommt, wenn das DOM erfolgreich ausgetauscht wurde wir suchen alle update element im responseXML holen das passende DOM element per document.getElementById wegen des Doppelpunktes und triggern einen custom Event darauf
  9. Hier reagieren wir auf den Custom Event von eben jsf:ajaxUpdate an dem main element haben wir ein data-Attribut „url“ wenn die anders ist, als das was grade in der Adresszeile steht, ändern wir die Adresszeile falls es sonst noch jemanden interessiert, feuern wir den custom event „page:change“
  10. popstate wird an dem main element haben wir ein data-Attribut „url“ wenn die anders ist, als das was grade in der Adresszeile steht, ändern wir die Adresszeile falls es sonst noch jemanden interessiert, feuern wir den custom event „page:change“
  11. Wir dekorieren den PartialViewContext Wenn serverseitig navigiert wird (als Ergebnis einer Action), rendert JSF alles. wir wollen aber nur unser „main“ Element rendern - also löschen wir alle renderids
  12. dreamIT is hiring Frank ist buchbar