SlideShare a Scribd company logo
1 of 22
JSF Lab
Here is one JSF application with the concepts:
• facelet
• resource
• named bean
• validation
• grouping components
• form submission
Environment
 Java EE 7
◦ Java EE 7 uses JSF 2.2
 GlassFish 4
INTRODUCTION JSF
Facelets
 JSF 1.x
◦ JSP as their default view technology
◦ Mismatch of lifecycle between JSP &
JSFs
 JSF 2.x
◦ Facelets became a de facto standard for
JSF
◦ in Version 2.0 of the JSF specification
Resource Location (1/2)
 resource directory
◦ at the root of WAR
◦ under META-INF
 my war file example:
Resource Location (2/2)
 my war file example:
 In JSF, I retrieve these files:
◦ <h:outputStylesheet library="css" name="styles.css"/>
◦ <h:outputScript library="scripts" name="somescript.js"/>
◦ <h:graphicImage library="images" name="logo.png"/>
LAB
• Demo the first version of JSF application
Tree of the example
Deploy and Run (1/3)
http://localhost:8080/jsf/faces/customer_data_entry.xhtml
Save invalid inputs
Deploy and Run (2/3)
http://localhost:8080/jsf/faces/customer_data_entry.xhtml
Save valid inputs
Deploy and Run (3/3)
HTML code
 <?xml version='1.0' encoding='UTF-8' ?>
 <!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head id="j_idt2">
 <title>Enter Customer Data</title>
 <link type="text/css" rel="stylesheet"
href="/jsf/faces/javax.faces.resource/styles.css;jsessionid=
f6a6a03cf586f6537c2c236ae198?ln=css" />
 </head>
 <body>
 <form id="customerForm" name="customerForm"
method="post"
action="/jsf/faces/customer_data_entry.xhtml;jsessionid=f6
a6a03cf586f6537c2c236ae198" enctype="application/x-
www-form-urlencoded">
 <input type="hidden" name="customerForm"
value="customerForm" />
 <table>
 <tbody>
 <tr>
 <td class="rightAlign">
 <label for="customerForm:firstName">First
Name:</label>
 </td>
 <td class="leftAlign">
 <input id="customerForm:firstName"
type="text" name="customerForm:firstName" />
 </td>
 </tr>
 <!-- IGNORE -->
 <tr>
 <td class="rightAlign"></td>
 <td class="leftAlign">
 <input type="submit"
name="customerForm:j_idt12" value="Save" />
 </td>
 </tr>
 </tbody>
 </table>
 <input type="hidden" name="javax.faces.ViewState"
id="j_id1:javax.faces.ViewState:0"
value="7091375556898980807:-6127233417766167060"
autocomplete="off" />
 </form>
 </body>
 </html>
OBSERVE FACELET
We should focus on how to transfer from facelet to
HTML
customer_data_entry.xhtml
 <?xml version='1.0' encoding='UTF-8' ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core">
 <h:head>
 <title>Enter Customer Data</title>
 </h:head>
 <h:body>
 <h:outputStylesheet library="css" name="styles.css"/>
 <h:form id="customerForm">
 <h:messages/>
 <h:panelGrid columns="2"
 columnClasses="rightAlign,leftAlign">
 <h:outputLabel for="firstName" value="First Name:">
 </h:outputLabel>
 <h:inputText id="firstName"
 label="First Name"
 value="#{customer.firstName}"
 required="true">
 <f:validateLength minimum="2" maximum="30">
 </f:validateLength>
 </h:inputText>
 <h:outputLabel for="lastName" value="Last Name:">
 </h:outputLabel>
 <h:inputText id="lastName"
 label="Last Name"
 value="#{customer.lastName}"
 required="true">
 <f:validateLength minimum="2" maximum="30">
 </f:validateLength>
 </h:inputText>
 <h:outputLabel for="email" value="Email:">
 </h:outputLabel>
 <h:inputText id="email"
 label="Email"
 value="#{customer.email}">
 <f:validateLength minimum="3" maximum="30">
 </f:validateLength>
 </h:inputText>
 <h:panelGroup></h:panelGroup>
 <h:commandButton action="confirmation" value="Save">
 </h:commandButton>
 </h:panelGrid>
 </h:form>
 </h:body>
 </html>
confirmation.xhtml
 <?xml version='1.0' encoding='UTF-8' ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:h="http://java.sun.com/jsf/html">
 <h:head>
 <title>Customer Data Entered</title>
 </h:head>
 <h:body>
 <h:panelGrid columns="2" columnClasses="rightAlign,leftAlign">
 <h:outputText value="First Name:"></h:outputText>
 <h:outputText value="#{customer.firstName}"></h:outputText>
 <h:outputText value="Last Name:"></h:outputText>
 <h:outputText value="#{customer.lastName}"></h:outputText>
 <h:outputText value="Email:"></h:outputText>
 <h:outputText value="#{customer.email}"></h:outputText>
 </h:panelGrid>
 </h:body>
 </html>
Overview the JSF page (1/2)
 <?xml version='1.0' encoding='UTF-8' ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core">
 <h:head>
 <title>Enter Customer Data</title>
 </h:head>
 <h:body>
 <h:outputStylesheet library="css" name="styles.css"/>
 <h:form id="customerForm">
 <!-- Ignore -->
 </h:form>
 </h:body>
 </html>
Overview the JSF page (2/2)
 Two namespaces:
◦ h: for HTML components
◦ f: for faces
 Analogous to standard HTML
 Load CSS (explained)
Look inside the form (1/3)
 <h:form id="customerForm">
 <h:messages/>
 <h:panelGrid columns="2"
 columnClasses="rightAlign,leftAlign">
 <h:outputLabel for="firstName" value="First Name:"></h:outputLabel>
 <h:inputText id="firstName"
 label="First Name"
 value="#{customer.firstName}"
 required="true">
 <f:validateLength minimum="2" maximum="30">
 </f:validateLength>
 </h:inputText>
 <!-- Ignore -->
 <h:panelGroup></h:panelGroup>
 <h:commandButton action="confirmation" value="Save"></h:commandButton>
 </h:panelGrid>
 </h:form>
Look inside the form (2/3)
 form does NOT need action and
method
◦ action: generated automatically
◦ method: always post
 messages is used to display any
messages
◦ explain latter
 panelGrid is like HTML table
◦ NOT declaring rows and columns
◦ declare the number of columns for each
Look inside the form (2/3)
 Observe the table and the facelet
◦ In panelGrid, one cell for one tag
◦ Use panelGroup to combine tags into 1 cell
 Observe the HTML file and the facelet
◦ columnClasses set the CSS class
 Invalid data is submitted
◦ required, validateLength chekcs the
inputs
◦ Error message is displayed at messages
 Click the label in page
◦ for (outputLabel) <-> id (inputText)
Value-binding expression
value="#{customer.firstName}”
value="#{customer.lastName}”
value="#{customer.email}”
 customer is the named
bean
 one customer object for
each request
Source code:
@Named
@RequestScoped
public class Customer {
private String firstName;
private String lastName;
private String email;
//public getter and setter
}
Navigation
 Valid inputs is submit
1. customer named bean’s is bound
2. To facelet confirmation.xhtml
3. This page also use value binding
expression
 Invalid inputs is submit
1. Navigate the same page
2. Show message
Reference
 Java EE 7 with GlassFish 4
Application Server

More Related Content

What's hot

QCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UIQCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UIOliver Häger
 
Angular 2 - Ahead of-time Compilation
Angular 2 - Ahead of-time CompilationAngular 2 - Ahead of-time Compilation
Angular 2 - Ahead of-time CompilationEyal Vardi
 
Web internship Yii Framework
Web internship  Yii FrameworkWeb internship  Yii Framework
Web internship Yii FrameworkNoveo
 
Django Forms: Best Practices, Tips, Tricks
Django Forms: Best Practices, Tips, TricksDjango Forms: Best Practices, Tips, Tricks
Django Forms: Best Practices, Tips, TricksShawn Rider
 
Technical training sample
Technical training sampleTechnical training sample
Technical training sampleopenerpwiki
 
Jinja2 Templates - San Francisco Flask Meetup
Jinja2 Templates - San Francisco Flask MeetupJinja2 Templates - San Francisco Flask Meetup
Jinja2 Templates - San Francisco Flask MeetupAlan Hamlett
 
网站无障碍阅读知识
网站无障碍阅读知识网站无障碍阅读知识
网站无障碍阅读知识ppanyong
 
MVC and Razor - Doc. v1.2
MVC and Razor - Doc. v1.2MVC and Razor - Doc. v1.2
MVC and Razor - Doc. v1.2Naji El Kotob
 
Aplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneAplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneRafael Felix da Silva
 
카카오커머스를 지탱하는 Angular
카카오커머스를 지탱하는 Angular카카오커머스를 지탱하는 Angular
카카오커머스를 지탱하는 Angularif kakao
 
Bad Form @ Form, Function & Class 2016
Bad Form @ Form, Function & Class 2016Bad Form @ Form, Function & Class 2016
Bad Form @ Form, Function & Class 2016cliener
 
Devoxx 2014-webComponents
Devoxx 2014-webComponentsDevoxx 2014-webComponents
Devoxx 2014-webComponentsCyril Balit
 
Two scoopsofdjango common patterns for forms
Two scoopsofdjango   common patterns for formsTwo scoopsofdjango   common patterns for forms
Two scoopsofdjango common patterns for formsShih-yi Wei
 
Mvc & java script
Mvc & java scriptMvc & java script
Mvc & java scriptEyal Vardi
 
Django class based views for beginners
Django class based views for beginnersDjango class based views for beginners
Django class based views for beginnersSpin Lai
 

What's hot (20)

QCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UIQCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UI
 
Django Bogotá. CBV
Django Bogotá. CBVDjango Bogotá. CBV
Django Bogotá. CBV
 
Angular 2 - Ahead of-time Compilation
Angular 2 - Ahead of-time CompilationAngular 2 - Ahead of-time Compilation
Angular 2 - Ahead of-time Compilation
 
Validation
ValidationValidation
Validation
 
Web internship Yii Framework
Web internship  Yii FrameworkWeb internship  Yii Framework
Web internship Yii Framework
 
Django Forms: Best Practices, Tips, Tricks
Django Forms: Best Practices, Tips, TricksDjango Forms: Best Practices, Tips, Tricks
Django Forms: Best Practices, Tips, Tricks
 
Technical training sample
Technical training sampleTechnical training sample
Technical training sample
 
Jinja2 Templates - San Francisco Flask Meetup
Jinja2 Templates - San Francisco Flask MeetupJinja2 Templates - San Francisco Flask Meetup
Jinja2 Templates - San Francisco Flask Meetup
 
Ruby - Design patterns tdc2011
Ruby - Design patterns tdc2011Ruby - Design patterns tdc2011
Ruby - Design patterns tdc2011
 
网站无障碍阅读知识
网站无障碍阅读知识网站无障碍阅读知识
网站无障碍阅读知识
 
MVC and Razor - Doc. v1.2
MVC and Razor - Doc. v1.2MVC and Razor - Doc. v1.2
MVC and Razor - Doc. v1.2
 
Backbone - TDC 2011 Floripa
Backbone - TDC 2011 FloripaBackbone - TDC 2011 Floripa
Backbone - TDC 2011 Floripa
 
Aplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneAplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com Backbone
 
카카오커머스를 지탱하는 Angular
카카오커머스를 지탱하는 Angular카카오커머스를 지탱하는 Angular
카카오커머스를 지탱하는 Angular
 
Bad Form @ Form, Function & Class 2016
Bad Form @ Form, Function & Class 2016Bad Form @ Form, Function & Class 2016
Bad Form @ Form, Function & Class 2016
 
Devoxx 2014-webComponents
Devoxx 2014-webComponentsDevoxx 2014-webComponents
Devoxx 2014-webComponents
 
Two scoopsofdjango common patterns for forms
Two scoopsofdjango   common patterns for formsTwo scoopsofdjango   common patterns for forms
Two scoopsofdjango common patterns for forms
 
Mvc & java script
Mvc & java scriptMvc & java script
Mvc & java script
 
Django class based views for beginners
Django class based views for beginnersDjango class based views for beginners
Django class based views for beginners
 
phptut2
phptut2phptut2
phptut2
 

Viewers also liked

Présentation Meteor soft shake
Présentation Meteor soft shakePrésentation Meteor soft shake
Présentation Meteor soft shakeMicha Roon
 
Work samples - Chris L.
Work samples - Chris L.Work samples - Chris L.
Work samples - Chris L.JMarie Kerr
 
Giao trinh-autocad-2007-pham van hau
Giao trinh-autocad-2007-pham van hauGiao trinh-autocad-2007-pham van hau
Giao trinh-autocad-2007-pham van hauDUNGZIDAN
 
Roadmap to a career in professional local government
Roadmap to a career in professional local governmentRoadmap to a career in professional local government
Roadmap to a career in professional local governmentdgoroff
 
Introduction to Search Marketing - Search Engine Optimisation
Introduction to Search Marketing - Search Engine OptimisationIntroduction to Search Marketing - Search Engine Optimisation
Introduction to Search Marketing - Search Engine OptimisationRhys Downard
 
The Major Shift in 21st Century Classroom
The Major Shift in 21st Century ClassroomThe Major Shift in 21st Century Classroom
The Major Shift in 21st Century ClassroomDooney Seed
 
Awaaz: The Vanguard of Citizen Engagement
Awaaz: The Vanguard of Citizen EngagementAwaaz: The Vanguard of Citizen Engagement
Awaaz: The Vanguard of Citizen Engagementkcx1
 
學測、指考單字統計
學測、指考單字統計學測、指考單字統計
學測、指考單字統計Yu-Ting Chen
 

Viewers also liked (12)

Présentation Meteor soft shake
Présentation Meteor soft shakePrésentation Meteor soft shake
Présentation Meteor soft shake
 
Maglevv
MaglevvMaglevv
Maglevv
 
Work samples - Chris L.
Work samples - Chris L.Work samples - Chris L.
Work samples - Chris L.
 
Giao trinh-autocad-2007-pham van hau
Giao trinh-autocad-2007-pham van hauGiao trinh-autocad-2007-pham van hau
Giao trinh-autocad-2007-pham van hau
 
sosiologi
sosiologisosiologi
sosiologi
 
Roadmap to a career in professional local government
Roadmap to a career in professional local governmentRoadmap to a career in professional local government
Roadmap to a career in professional local government
 
O ring chart
O ring chartO ring chart
O ring chart
 
Introduction to Search Marketing - Search Engine Optimisation
Introduction to Search Marketing - Search Engine OptimisationIntroduction to Search Marketing - Search Engine Optimisation
Introduction to Search Marketing - Search Engine Optimisation
 
Avikalp
AvikalpAvikalp
Avikalp
 
The Major Shift in 21st Century Classroom
The Major Shift in 21st Century ClassroomThe Major Shift in 21st Century Classroom
The Major Shift in 21st Century Classroom
 
Awaaz: The Vanguard of Citizen Engagement
Awaaz: The Vanguard of Citizen EngagementAwaaz: The Vanguard of Citizen Engagement
Awaaz: The Vanguard of Citizen Engagement
 
學測、指考單字統計
學測、指考單字統計學測、指考單字統計
學測、指考單字統計
 

Similar to Jsf lab

Vaadin Components @ Angular U
Vaadin Components @ Angular UVaadin Components @ Angular U
Vaadin Components @ Angular UJoonas Lehtinen
 
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0Arun Gupta
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)Ajay Khatri
 
HTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowHTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowPrabhdeep Singh
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and ImprovedTimothy Fisher
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Hugo Hamon
 
Java script advanced frame
Java script advanced frameJava script advanced frame
Java script advanced frameH K
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3masahiroookubo
 
Odoo Experience 2018 - Develop an App with the Odoo Framework
Odoo Experience 2018 - Develop an App with the Odoo FrameworkOdoo Experience 2018 - Develop an App with the Odoo Framework
Odoo Experience 2018 - Develop an App with the Odoo FrameworkElínAnna Jónasdóttir
 
Flask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshopsFlask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshopsAlex Eftimie
 

Similar to Jsf lab (20)

Vaadin Components @ Angular U
Vaadin Components @ Angular UVaadin Components @ Angular U
Vaadin Components @ Angular U
 
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)
 
Stole16
Stole16Stole16
Stole16
 
前端概述
前端概述前端概述
前端概述
 
How to connect redis and mule esb using spring data redis module
How to connect redis and mule esb using spring data redis moduleHow to connect redis and mule esb using spring data redis module
How to connect redis and mule esb using spring data redis module
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
 
HTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowHTL(Sightly) - All you need to know
HTL(Sightly) - All you need to know
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2
 
Java script advanced frame
Java script advanced frameJava script advanced frame
Java script advanced frame
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3
 
Odoo Experience 2018 - Develop an App with the Odoo Framework
Odoo Experience 2018 - Develop an App with the Odoo FrameworkOdoo Experience 2018 - Develop an App with the Odoo Framework
Odoo Experience 2018 - Develop an App with the Odoo Framework
 
Flask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshopsFlask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshops
 
jQuery
jQueryjQuery
jQuery
 
Rest hello world_tutorial
Rest hello world_tutorialRest hello world_tutorial
Rest hello world_tutorial
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
 
Introduccion a HTML5
Introduccion a HTML5Introduccion a HTML5
Introduccion a HTML5
 
html5
html5html5
html5
 

Recently uploaded

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
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 CCTVshikhaohhpro
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
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.pdfkalichargn70th171
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 

Recently uploaded (20)

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
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
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
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
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 

Jsf lab

  • 1. JSF Lab Here is one JSF application with the concepts: • facelet • resource • named bean • validation • grouping components • form submission
  • 2. Environment  Java EE 7 ◦ Java EE 7 uses JSF 2.2  GlassFish 4
  • 4. Facelets  JSF 1.x ◦ JSP as their default view technology ◦ Mismatch of lifecycle between JSP & JSFs  JSF 2.x ◦ Facelets became a de facto standard for JSF ◦ in Version 2.0 of the JSF specification
  • 5. Resource Location (1/2)  resource directory ◦ at the root of WAR ◦ under META-INF  my war file example:
  • 6. Resource Location (2/2)  my war file example:  In JSF, I retrieve these files: ◦ <h:outputStylesheet library="css" name="styles.css"/> ◦ <h:outputScript library="scripts" name="somescript.js"/> ◦ <h:graphicImage library="images" name="logo.png"/>
  • 7. LAB • Demo the first version of JSF application
  • 8. Tree of the example
  • 9. Deploy and Run (1/3) http://localhost:8080/jsf/faces/customer_data_entry.xhtml Save invalid inputs
  • 10. Deploy and Run (2/3) http://localhost:8080/jsf/faces/customer_data_entry.xhtml Save valid inputs
  • 11. Deploy and Run (3/3) HTML code  <?xml version='1.0' encoding='UTF-8' ?>  <!DOCTYPE html>  <html xmlns="http://www.w3.org/1999/xhtml">  <head id="j_idt2">  <title>Enter Customer Data</title>  <link type="text/css" rel="stylesheet" href="/jsf/faces/javax.faces.resource/styles.css;jsessionid= f6a6a03cf586f6537c2c236ae198?ln=css" />  </head>  <body>  <form id="customerForm" name="customerForm" method="post" action="/jsf/faces/customer_data_entry.xhtml;jsessionid=f6 a6a03cf586f6537c2c236ae198" enctype="application/x- www-form-urlencoded">  <input type="hidden" name="customerForm" value="customerForm" />  <table>  <tbody>  <tr>  <td class="rightAlign">  <label for="customerForm:firstName">First Name:</label>  </td>  <td class="leftAlign">  <input id="customerForm:firstName" type="text" name="customerForm:firstName" />  </td>  </tr>  <!-- IGNORE -->  <tr>  <td class="rightAlign"></td>  <td class="leftAlign">  <input type="submit" name="customerForm:j_idt12" value="Save" />  </td>  </tr>  </tbody>  </table>  <input type="hidden" name="javax.faces.ViewState" id="j_id1:javax.faces.ViewState:0" value="7091375556898980807:-6127233417766167060" autocomplete="off" />  </form>  </body>  </html>
  • 12. OBSERVE FACELET We should focus on how to transfer from facelet to HTML
  • 13. customer_data_entry.xhtml  <?xml version='1.0' encoding='UTF-8' ?>  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml"  xmlns:h="http://java.sun.com/jsf/html"  xmlns:f="http://java.sun.com/jsf/core">  <h:head>  <title>Enter Customer Data</title>  </h:head>  <h:body>  <h:outputStylesheet library="css" name="styles.css"/>  <h:form id="customerForm">  <h:messages/>  <h:panelGrid columns="2"  columnClasses="rightAlign,leftAlign">  <h:outputLabel for="firstName" value="First Name:">  </h:outputLabel>  <h:inputText id="firstName"  label="First Name"  value="#{customer.firstName}"  required="true">  <f:validateLength minimum="2" maximum="30">  </f:validateLength>  </h:inputText>  <h:outputLabel for="lastName" value="Last Name:">  </h:outputLabel>  <h:inputText id="lastName"  label="Last Name"  value="#{customer.lastName}"  required="true">  <f:validateLength minimum="2" maximum="30">  </f:validateLength>  </h:inputText>  <h:outputLabel for="email" value="Email:">  </h:outputLabel>  <h:inputText id="email"  label="Email"  value="#{customer.email}">  <f:validateLength minimum="3" maximum="30">  </f:validateLength>  </h:inputText>  <h:panelGroup></h:panelGroup>  <h:commandButton action="confirmation" value="Save">  </h:commandButton>  </h:panelGrid>  </h:form>  </h:body>  </html>
  • 14. confirmation.xhtml  <?xml version='1.0' encoding='UTF-8' ?>  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml"  xmlns:h="http://java.sun.com/jsf/html">  <h:head>  <title>Customer Data Entered</title>  </h:head>  <h:body>  <h:panelGrid columns="2" columnClasses="rightAlign,leftAlign">  <h:outputText value="First Name:"></h:outputText>  <h:outputText value="#{customer.firstName}"></h:outputText>  <h:outputText value="Last Name:"></h:outputText>  <h:outputText value="#{customer.lastName}"></h:outputText>  <h:outputText value="Email:"></h:outputText>  <h:outputText value="#{customer.email}"></h:outputText>  </h:panelGrid>  </h:body>  </html>
  • 15. Overview the JSF page (1/2)  <?xml version='1.0' encoding='UTF-8' ?>  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml"  xmlns:h="http://java.sun.com/jsf/html"  xmlns:f="http://java.sun.com/jsf/core">  <h:head>  <title>Enter Customer Data</title>  </h:head>  <h:body>  <h:outputStylesheet library="css" name="styles.css"/>  <h:form id="customerForm">  <!-- Ignore -->  </h:form>  </h:body>  </html>
  • 16. Overview the JSF page (2/2)  Two namespaces: ◦ h: for HTML components ◦ f: for faces  Analogous to standard HTML  Load CSS (explained)
  • 17. Look inside the form (1/3)  <h:form id="customerForm">  <h:messages/>  <h:panelGrid columns="2"  columnClasses="rightAlign,leftAlign">  <h:outputLabel for="firstName" value="First Name:"></h:outputLabel>  <h:inputText id="firstName"  label="First Name"  value="#{customer.firstName}"  required="true">  <f:validateLength minimum="2" maximum="30">  </f:validateLength>  </h:inputText>  <!-- Ignore -->  <h:panelGroup></h:panelGroup>  <h:commandButton action="confirmation" value="Save"></h:commandButton>  </h:panelGrid>  </h:form>
  • 18. Look inside the form (2/3)  form does NOT need action and method ◦ action: generated automatically ◦ method: always post  messages is used to display any messages ◦ explain latter  panelGrid is like HTML table ◦ NOT declaring rows and columns ◦ declare the number of columns for each
  • 19. Look inside the form (2/3)  Observe the table and the facelet ◦ In panelGrid, one cell for one tag ◦ Use panelGroup to combine tags into 1 cell  Observe the HTML file and the facelet ◦ columnClasses set the CSS class  Invalid data is submitted ◦ required, validateLength chekcs the inputs ◦ Error message is displayed at messages  Click the label in page ◦ for (outputLabel) <-> id (inputText)
  • 20. Value-binding expression value="#{customer.firstName}” value="#{customer.lastName}” value="#{customer.email}”  customer is the named bean  one customer object for each request Source code: @Named @RequestScoped public class Customer { private String firstName; private String lastName; private String email; //public getter and setter }
  • 21. Navigation  Valid inputs is submit 1. customer named bean’s is bound 2. To facelet confirmation.xhtml 3. This page also use value binding expression  Invalid inputs is submit 1. Navigate the same page 2. Show message
  • 22. Reference  Java EE 7 with GlassFish 4 Application Server