SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Go Fullstack: JSF for public sites
Michael Kurz | IRIAN
Agenda

• Motivation
• Architecture with/without EE 6 container
• Putting the pieces together (CDI and CODI)
• JSF and GET-Requests
• RESTful URLs with JSF and PrettyFaces
• Demonstrations and examples
Motivation

• http://scientific-consensus.com
• From GWT to JavaServer Faces
• Lightweight Java EE 6 architecture
• Does JSF really support HTTP GET?
Architecture and Technology Stack

   Architecture   With EE 6 container   No EE 6 container


   Presentation    JSF, CDI, CODI       JSF, CDI, CODI



     Service          EJB, CDI             CDI, CODI



   Data access        EJB, JPA          CDI, CODI, JPA
MyFaces Extensions CDI

• Portable extension of CDI
• Simplifies development with CDI and JSF
• Several modules:
 • JSF 1.2 and 2.0
 • JPA, bean validation...
• Works with:
 • CDI: OpenWebBeans, Weld
 • JSF: MyFaces, Mojarra (1.2 und 2.0)
• Watch out Apache DeltaSpike
Management of Persistence Context

• With Java EE container (EJB)

 @javax.ejb.Stateless
 public class CustomerRepository {
   @PersistenceContext private EntityManager em;
 }


• Without Java EE container (CDI + CODI)

 @ApplicationScoped
 public class CustomerRepository {
   @Inject private EntityManager em;
 }
Transaction Management

• With Java EE container
 • Transactions managed by container (@TransactionAttribute)
• Without Java EE container (CDI only)
 • Transactions managed by CODI

 @ApplicationScoped
 public class CustomerService {
   @Inject
   private CustomerRepository customerRepository;

     @Transactional
     public void saveUser(User user) {...}
 }
Demonstration




• Architecture with CDI and CODI




Beispiel: https://github.com/jsflive/mymail-get
The Web versus JSF




                 vs.
      HTTP GET         HTTP POST
JSF requests

• HTTP requests in classic JSF

            page1.xhtml               page2.xhtml               page3.xhtml
    GET                      POST                      POST

          /faces/page1.jsf          /faces/page1.jsf          /faces/page2.jsf


• Problems with HTTP POST:
 • Page reload problematic
 • URL in browser one step behind
 • Lack of bookmarkability/direct linking
• JSF 2: h:link, h:button and view parameters
JSF 2: Navigation with h:link and h:button

• Navigation target in attribut outcome
 <h:link outcome="/page1.xhtml" value="Page 1"/>
 <h:link outcome="/page2.xhtml" value="Page 2">
   <f:param name="para" value="1"/>
 </h:link>
 <h:button outcome="/page3.xhtml" value="Page 3"/>

• Renders link oder button (h:form not necessary)
 <a href="/page1.jsf">Page 1</a>
 <a href="/page2.jsf?para=1">Page 2</a>
 <input type="button" value="Page 3"
     onclick="window.location.href = '/pag3.jsf'"/>
JSF 2: View Parameters

• Bind request parameters to bean properties
• Tag f:viewParam in f:metadata

 <f:metadata>
   <f:viewParam name="id" value="#{myBean.id}"/>
 </f:metadata>

                                                   Converted and
 @Named @RequestScoped                               validated
 public class MyBean {
   private long id;
   public long getId() {return id;}
   public void setId(long id) {this.id = id;}
 }
What about view actions?

• JSF 2.0 "forgot" about them
• Alternative: PreRenderViewEvent
 <f:event type="preRenderView" listener="#{bean.preRender}"/>


• Alternative: CODI @PreRenderView
• Real view actions part of JSF 2.2

 <f:metadata>
   <f:viewParam name="id" value="#{bean.id}"/>
   <f:viewAction action="#{bean.load}"/>
 </f:metadata>
Post-Redirect-Get with JSF 2

• Request /faces/myPage.xhtml?id=1
 <h:form>
   <h:commandButton action="#{myBean.save}" value="Save"/>
   <h:commandButton value="Cancel" immediate="true"
       action="myPage?faces-redirect=true&amp;
                      faces-include-view-params=true"/>
 </h:form>

 @Named @RequestScoped
 public class MyBean {
   public String save() {
     return "myPage?faces-redirect=true"
            + "&faces-include-view-params=true";
   }
 }
Demonstration




• GET requests with h:link and h:button
• View Parameters
• Post-Redirect-Get with JSF

Beispiel: https://github.com/jsflive/jsf-get02
RESTful URLs



   http://myshop.at/node.html?mode=list&cat=1234




         http://myshop.at/products/books
Why RESTful URLs?

• Readability
• Search Engine Optimization (SEO)
• Confidence
• Looks prettier
RESTful URLs for JSF

• PrettyFaces: RESTful URLS for JSF
 • By OCPsoft, Open Source
• Features:
 • URL Rewriting
 • Enhanced navigation
 • Page actions
 • Seamless integration into JSF
 • Easy configuration
PrettyFaces: Example 1 (1)

• Remove "JSF parts" of URL



          http://myshop.at/faces/account.xhtml




               http://myshop.at/account
PrettyFaces: Example 1 (2)

• Configuration in pretty-config.xml
 <url-mapping id="account">
   <pattern value="/account"/>
   <view-id value="/faces/account.xhtml"/>
 </url-mapping>


• Annotation based configuration

 @Named @RequestScoped
 @URLMapping(id="account", pattern="/account",
     viewId="/faces/account.xhtml")
 public class AccountPage {}
PrettyFaces: Example 2 (1)

• Map part of URL to parameter



  http://myshop.at/faces/products/details.xhtml?id=123




              http://myshop.at/product/123
PrettyFaces: Example 2 (2)

• Configuration in pretty-config.xml
 <url-mapping id="productDetails">
   <pattern value="/product/#{id}"/>
   <view-id value="/faces/products/details.xhtml"/>
 </url-mapping>


• Path parameter used in view parameter

 <f:metadata>
   <f:viewParam name="id" value="#{bean.id}"/>
 </f:metadata>
 <f:event type="preRenderView" listener="#{bean.preRender}"/>
Demonstration




• PrettyFaces




Beispiel: https://github.com/jsflive/jsf-get03
Conclusion

• Lightweight Architecture with Java EE 6
• JSF 2 simplifies GET support
• PrettyFaces
• Necessary for the intranet?
Curious?




• Kurz, Marinschek, Müllan:
  JavaServer Faces 2.0, dpunkt.Verlag
• IRIAN JSF@Work Online-Tutorial
  http://jsfatwork.irian.at
• JSFlive Weblog
  http://jsflive.wordpress.com

Weitere ähnliche Inhalte

Was ist angesagt?

CUST-1 Share Document Library Extension Points
CUST-1 Share Document Library Extension PointsCUST-1 Share Document Library Extension Points
CUST-1 Share Document Library Extension PointsAlfresco Software
 
Two scoops of django 1.6 - Ch7, Ch8
Two scoops of django 1.6  - Ch7, Ch8Two scoops of django 1.6  - Ch7, Ch8
Two scoops of django 1.6 - Ch7, Ch8flywindy
 
Suportando Aplicações Multi-tenancy com Java EE
Suportando Aplicações Multi-tenancy com Java EESuportando Aplicações Multi-tenancy com Java EE
Suportando Aplicações Multi-tenancy com Java EERodrigo Cândido da Silva
 
Templates
TemplatesTemplates
Templatessoon
 
MongoDB & NoSQL 101
 MongoDB & NoSQL 101 MongoDB & NoSQL 101
MongoDB & NoSQL 101Jollen Chen
 
Staying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPStaying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPOscar Merida
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsCarol McDonald
 
Session 35 - Design Patterns
Session 35 - Design PatternsSession 35 - Design Patterns
Session 35 - Design PatternsPawanMM
 
Alfresco tech talk live share extensibility metadata and actions for 4.1
Alfresco tech talk live share extensibility metadata and actions for 4.1Alfresco tech talk live share extensibility metadata and actions for 4.1
Alfresco tech talk live share extensibility metadata and actions for 4.1Alfresco Software
 
Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1Michał Orman
 
Introduction to Backbone.js for Rails developers
Introduction to Backbone.js for Rails developersIntroduction to Backbone.js for Rails developers
Introduction to Backbone.js for Rails developersAoteaStudios
 
e-suap - client technologies- english version
e-suap - client technologies- english versione-suap - client technologies- english version
e-suap - client technologies- english versionSabino Labarile
 
Customizing the Document Library
Customizing the Document LibraryCustomizing the Document Library
Customizing the Document LibraryAlfresco Software
 
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces Skills Matter
 
Hyperproductive JSF 2.0 @ JavaOne Brazil 2010
Hyperproductive JSF 2.0 @ JavaOne Brazil 2010Hyperproductive JSF 2.0 @ JavaOne Brazil 2010
Hyperproductive JSF 2.0 @ JavaOne Brazil 2010Arun Gupta
 
Intorduction of Playframework
Intorduction of PlayframeworkIntorduction of Playframework
Intorduction of Playframeworkmaltiyadav
 
Tikal's Backbone_js introduction workshop
Tikal's Backbone_js introduction workshopTikal's Backbone_js introduction workshop
Tikal's Backbone_js introduction workshopTikal Knowledge
 
Spring java config
Spring java configSpring java config
Spring java configSukjin Yun
 

Was ist angesagt? (20)

Backbone js-slides
Backbone js-slidesBackbone js-slides
Backbone js-slides
 
CUST-1 Share Document Library Extension Points
CUST-1 Share Document Library Extension PointsCUST-1 Share Document Library Extension Points
CUST-1 Share Document Library Extension Points
 
Two scoops of django 1.6 - Ch7, Ch8
Two scoops of django 1.6  - Ch7, Ch8Two scoops of django 1.6  - Ch7, Ch8
Two scoops of django 1.6 - Ch7, Ch8
 
Suportando Aplicações Multi-tenancy com Java EE
Suportando Aplicações Multi-tenancy com Java EESuportando Aplicações Multi-tenancy com Java EE
Suportando Aplicações Multi-tenancy com Java EE
 
Templates
TemplatesTemplates
Templates
 
MongoDB & NoSQL 101
 MongoDB & NoSQL 101 MongoDB & NoSQL 101
MongoDB & NoSQL 101
 
Staying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPStaying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHP
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.js
 
Session 35 - Design Patterns
Session 35 - Design PatternsSession 35 - Design Patterns
Session 35 - Design Patterns
 
Alfresco tech talk live share extensibility metadata and actions for 4.1
Alfresco tech talk live share extensibility metadata and actions for 4.1Alfresco tech talk live share extensibility metadata and actions for 4.1
Alfresco tech talk live share extensibility metadata and actions for 4.1
 
Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1
 
Introduction to Backbone.js for Rails developers
Introduction to Backbone.js for Rails developersIntroduction to Backbone.js for Rails developers
Introduction to Backbone.js for Rails developers
 
e-suap - client technologies- english version
e-suap - client technologies- english versione-suap - client technologies- english version
e-suap - client technologies- english version
 
netbeans
netbeansnetbeans
netbeans
 
Customizing the Document Library
Customizing the Document LibraryCustomizing the Document Library
Customizing the Document Library
 
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces
 
Hyperproductive JSF 2.0 @ JavaOne Brazil 2010
Hyperproductive JSF 2.0 @ JavaOne Brazil 2010Hyperproductive JSF 2.0 @ JavaOne Brazil 2010
Hyperproductive JSF 2.0 @ JavaOne Brazil 2010
 
Intorduction of Playframework
Intorduction of PlayframeworkIntorduction of Playframework
Intorduction of Playframework
 
Tikal's Backbone_js introduction workshop
Tikal's Backbone_js introduction workshopTikal's Backbone_js introduction workshop
Tikal's Backbone_js introduction workshop
 
Spring java config
Spring java configSpring java config
Spring java config
 

Ähnlich wie Go Fullstack: JSF for public sites

The Future of Plugin Dev
The Future of Plugin DevThe Future of Plugin Dev
The Future of Plugin DevBrandon Kelly
 
RichFaces 4 Component Deep Dive - JAX/JSFSummit
RichFaces 4 Component Deep Dive - JAX/JSFSummitRichFaces 4 Component Deep Dive - JAX/JSFSummit
RichFaces 4 Component Deep Dive - JAX/JSFSummitbalunasj
 
Java EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVCJava EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVCJosh Juneau
 
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...Lucidworks
 
London React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor CharyparLondon React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor CharyparReact London Community
 
JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011Arun Gupta
 
Hypermedia: The Missing Element to Building Adaptable Web APIs in Rails
Hypermedia: The Missing Element to Building Adaptable Web APIs in RailsHypermedia: The Missing Element to Building Adaptable Web APIs in Rails
Hypermedia: The Missing Element to Building Adaptable Web APIs in RailsToru Kawamura
 
Going Above JSF 2.0 with RichFaces and Seam
Going Above JSF 2.0 with RichFaces and SeamGoing Above JSF 2.0 with RichFaces and Seam
Going Above JSF 2.0 with RichFaces and SeamLincoln III
 
SPTechCon Boston 2015 - Utilizing jQuery in SharePoint
SPTechCon Boston 2015 - Utilizing jQuery in SharePointSPTechCon Boston 2015 - Utilizing jQuery in SharePoint
SPTechCon Boston 2015 - Utilizing jQuery in SharePointMark Rackley
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
SPTechCon DevDays - SharePoint & jQuery
SPTechCon DevDays - SharePoint & jQuerySPTechCon DevDays - SharePoint & jQuery
SPTechCon DevDays - SharePoint & jQueryMark Rackley
 
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012crokitta
 
Code First with Serverless Azure Functions
Code First with Serverless Azure FunctionsCode First with Serverless Azure Functions
Code First with Serverless Azure FunctionsJeremy Likness
 
Going Serverless with Azure Functions in .NET
Going Serverless with Azure Functions in .NETGoing Serverless with Azure Functions in .NET
Going Serverless with Azure Functions in .NETJeremy Likness
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a bossFrancisco Ribeiro
 
From Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) AgainFrom Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) Againjonknapp
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizationsChris Love
 

Ähnlich wie Go Fullstack: JSF for public sites (20)

The Future of Plugin Dev
The Future of Plugin DevThe Future of Plugin Dev
The Future of Plugin Dev
 
RichFaces 4 Component Deep Dive - JAX/JSFSummit
RichFaces 4 Component Deep Dive - JAX/JSFSummitRichFaces 4 Component Deep Dive - JAX/JSFSummit
RichFaces 4 Component Deep Dive - JAX/JSFSummit
 
Java EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVCJava EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVC
 
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
 
London React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor CharyparLondon React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor Charypar
 
JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011
 
Hypermedia: The Missing Element to Building Adaptable Web APIs in Rails
Hypermedia: The Missing Element to Building Adaptable Web APIs in RailsHypermedia: The Missing Element to Building Adaptable Web APIs in Rails
Hypermedia: The Missing Element to Building Adaptable Web APIs in Rails
 
Going Above JSF 2.0 with RichFaces and Seam
Going Above JSF 2.0 with RichFaces and SeamGoing Above JSF 2.0 with RichFaces and Seam
Going Above JSF 2.0 with RichFaces and Seam
 
SPTechCon Boston 2015 - Utilizing jQuery in SharePoint
SPTechCon Boston 2015 - Utilizing jQuery in SharePointSPTechCon Boston 2015 - Utilizing jQuery in SharePoint
SPTechCon Boston 2015 - Utilizing jQuery in SharePoint
 
Jsf2.0 -4
Jsf2.0 -4Jsf2.0 -4
Jsf2.0 -4
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
SPTechCon DevDays - SharePoint & jQuery
SPTechCon DevDays - SharePoint & jQuerySPTechCon DevDays - SharePoint & jQuery
SPTechCon DevDays - SharePoint & jQuery
 
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
 
Code First with Serverless Azure Functions
Code First with Serverless Azure FunctionsCode First with Serverless Azure Functions
Code First with Serverless Azure Functions
 
DirectToWeb 2.0
DirectToWeb 2.0DirectToWeb 2.0
DirectToWeb 2.0
 
Going Serverless with Azure Functions in .NET
Going Serverless with Azure Functions in .NETGoing Serverless with Azure Functions in .NET
Going Serverless with Azure Functions in .NET
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a boss
 
Introducing jee7 – jsf 2
Introducing jee7 – jsf 2Introducing jee7 – jsf 2
Introducing jee7 – jsf 2
 
From Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) AgainFrom Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) Again
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizations
 

Kürzlich hochgeladen

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
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 textsMaria Levchenko
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
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 2024Rafal Los
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 

Kürzlich hochgeladen (20)

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 

Go Fullstack: JSF for public sites

  • 1. Go Fullstack: JSF for public sites Michael Kurz | IRIAN
  • 2. Agenda • Motivation • Architecture with/without EE 6 container • Putting the pieces together (CDI and CODI) • JSF and GET-Requests • RESTful URLs with JSF and PrettyFaces • Demonstrations and examples
  • 3. Motivation • http://scientific-consensus.com • From GWT to JavaServer Faces • Lightweight Java EE 6 architecture • Does JSF really support HTTP GET?
  • 4. Architecture and Technology Stack Architecture With EE 6 container No EE 6 container Presentation JSF, CDI, CODI JSF, CDI, CODI Service EJB, CDI CDI, CODI Data access EJB, JPA CDI, CODI, JPA
  • 5. MyFaces Extensions CDI • Portable extension of CDI • Simplifies development with CDI and JSF • Several modules: • JSF 1.2 and 2.0 • JPA, bean validation... • Works with: • CDI: OpenWebBeans, Weld • JSF: MyFaces, Mojarra (1.2 und 2.0) • Watch out Apache DeltaSpike
  • 6. Management of Persistence Context • With Java EE container (EJB) @javax.ejb.Stateless public class CustomerRepository { @PersistenceContext private EntityManager em; } • Without Java EE container (CDI + CODI) @ApplicationScoped public class CustomerRepository { @Inject private EntityManager em; }
  • 7. Transaction Management • With Java EE container • Transactions managed by container (@TransactionAttribute) • Without Java EE container (CDI only) • Transactions managed by CODI @ApplicationScoped public class CustomerService { @Inject private CustomerRepository customerRepository; @Transactional public void saveUser(User user) {...} }
  • 8. Demonstration • Architecture with CDI and CODI Beispiel: https://github.com/jsflive/mymail-get
  • 9. The Web versus JSF vs. HTTP GET HTTP POST
  • 10. JSF requests • HTTP requests in classic JSF page1.xhtml page2.xhtml page3.xhtml GET POST POST /faces/page1.jsf /faces/page1.jsf /faces/page2.jsf • Problems with HTTP POST: • Page reload problematic • URL in browser one step behind • Lack of bookmarkability/direct linking • JSF 2: h:link, h:button and view parameters
  • 11. JSF 2: Navigation with h:link and h:button • Navigation target in attribut outcome <h:link outcome="/page1.xhtml" value="Page 1"/> <h:link outcome="/page2.xhtml" value="Page 2"> <f:param name="para" value="1"/> </h:link> <h:button outcome="/page3.xhtml" value="Page 3"/> • Renders link oder button (h:form not necessary) <a href="/page1.jsf">Page 1</a> <a href="/page2.jsf?para=1">Page 2</a> <input type="button" value="Page 3" onclick="window.location.href = '/pag3.jsf'"/>
  • 12. JSF 2: View Parameters • Bind request parameters to bean properties • Tag f:viewParam in f:metadata <f:metadata> <f:viewParam name="id" value="#{myBean.id}"/> </f:metadata> Converted and @Named @RequestScoped validated public class MyBean { private long id; public long getId() {return id;} public void setId(long id) {this.id = id;} }
  • 13. What about view actions? • JSF 2.0 "forgot" about them • Alternative: PreRenderViewEvent <f:event type="preRenderView" listener="#{bean.preRender}"/> • Alternative: CODI @PreRenderView • Real view actions part of JSF 2.2 <f:metadata> <f:viewParam name="id" value="#{bean.id}"/> <f:viewAction action="#{bean.load}"/> </f:metadata>
  • 14. Post-Redirect-Get with JSF 2 • Request /faces/myPage.xhtml?id=1 <h:form> <h:commandButton action="#{myBean.save}" value="Save"/> <h:commandButton value="Cancel" immediate="true" action="myPage?faces-redirect=true&amp; faces-include-view-params=true"/> </h:form> @Named @RequestScoped public class MyBean { public String save() { return "myPage?faces-redirect=true" + "&faces-include-view-params=true"; } }
  • 15. Demonstration • GET requests with h:link and h:button • View Parameters • Post-Redirect-Get with JSF Beispiel: https://github.com/jsflive/jsf-get02
  • 16. RESTful URLs http://myshop.at/node.html?mode=list&cat=1234 http://myshop.at/products/books
  • 17. Why RESTful URLs? • Readability • Search Engine Optimization (SEO) • Confidence • Looks prettier
  • 18. RESTful URLs for JSF • PrettyFaces: RESTful URLS for JSF • By OCPsoft, Open Source • Features: • URL Rewriting • Enhanced navigation • Page actions • Seamless integration into JSF • Easy configuration
  • 19. PrettyFaces: Example 1 (1) • Remove "JSF parts" of URL http://myshop.at/faces/account.xhtml http://myshop.at/account
  • 20. PrettyFaces: Example 1 (2) • Configuration in pretty-config.xml <url-mapping id="account"> <pattern value="/account"/> <view-id value="/faces/account.xhtml"/> </url-mapping> • Annotation based configuration @Named @RequestScoped @URLMapping(id="account", pattern="/account", viewId="/faces/account.xhtml") public class AccountPage {}
  • 21. PrettyFaces: Example 2 (1) • Map part of URL to parameter http://myshop.at/faces/products/details.xhtml?id=123 http://myshop.at/product/123
  • 22. PrettyFaces: Example 2 (2) • Configuration in pretty-config.xml <url-mapping id="productDetails"> <pattern value="/product/#{id}"/> <view-id value="/faces/products/details.xhtml"/> </url-mapping> • Path parameter used in view parameter <f:metadata> <f:viewParam name="id" value="#{bean.id}"/> </f:metadata> <f:event type="preRenderView" listener="#{bean.preRender}"/>
  • 24. Conclusion • Lightweight Architecture with Java EE 6 • JSF 2 simplifies GET support • PrettyFaces • Necessary for the intranet?
  • 25. Curious? • Kurz, Marinschek, Müllan: JavaServer Faces 2.0, dpunkt.Verlag • IRIAN JSF@Work Online-Tutorial http://jsfatwork.irian.at • JSFlive Weblog http://jsflive.wordpress.com