SlideShare a Scribd company logo
1 of 25
Download to read offline
Java Server Faces 2.2	

PrimeFaces 4.0	

Servlet 3.0	

Maven
java web
Mario Jorge Pereira
14

20

13

20

12

20

11

20

10

20

09

20

08

20

07

20

06

20

05

20

04

20

03

20

02

20
Agenda
• Maven	

• Servlet 3.0	

• Java Server Faces - JSF 2.2	

• PrimeFaces - Prime 4.0
File > New > Other…
Skip archetype selection
br.com.mariojp.labjsf
Project > Properties > Project Facets
Runtime

são
Ver
et e
Fac
<project 	
xmlns="http://maven.apache.org/POM/4.0.0" 	
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"	
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">	
	 <modelVersion>4.0.0</modelVersion>	
	 <groupId>br.com.mariojp</groupId>	
	 <artifactId>labjsf</artifactId>	
	 <version>0.0.1-SNAPSHOT</version>	
	 <name>labjsf</name>	
	 <packaging>war</packaging>	
</project>

pom.xml
adicionando jsf 2.2 e servlet 3.0

<project ... >	
...	
	 <dependencies>	
	 	 <dependency>	
	 	 	 <groupId>com.sun.faces</groupId>	
	 	 	 <artifactId>jsf-api</artifactId>	
	 	 	 <version>2.2.2</version>	
	 	 </dependency>	
	 	 <dependency>	
	 	 	 <groupId>com.sun.faces</groupId>	
	 	 	 <artifactId>jsf-impl</artifactId>	
	 	 	 <version>2.2.2</version>	
	 	 </dependency>	
	 	 <dependency>	
	 	 	 <groupId>javax.servlet</groupId>	
	 	 	 <artifactId>javax.servlet-api</artifactId>	
	 	 	 <version>3.0.1</version>	
	 	 </dependency>	
	 </dependencies>	
</project>

pom.xml
adicionando commons-fileupload

<project ... >	
...	
	 <dependencies>	
...	
	 	 <dependency>	
	 	 	 <groupId>commons-fileupload</groupId>	
	 	 	 <artifactId>commons-fileupload</artifactId>	
	 	 	 <version>1.3</version>	
	 	 </dependency>	
	 </dependencies>	
</project>

pom.xml
adicionando primefaces

<project ... >	
...	
	 <dependencies>	
...	
	 	 <dependency>	
	 	 	 <groupId>org.primefaces.themes</groupId>	
	 	 	 <artifactId>all-themes</artifactId>	
	 	 	 <version>1.0.10</version>	
	 	 </dependency>	
	 	 <dependency>	
	 	 	 <groupId>org.primefaces</groupId>	
	 	 	 <artifactId>primefaces</artifactId>	
	 	 	 <version>4.0</version>	
	 	 </dependency>	
	 <repositories>	
	 	 <repository>	
	 	 	 <id>prime-repo</id>	
	 	 	 <name>PrimeFaces Maven Repository</name>	
	 	 	 <url>http://repository.primefaces.org</url>	
	 	 	 <layout>default</layout>	
	 	 </repository>	
	 </repositories>	
</project>

pom.xml
Mapeando o Servlet do JSF
<?xml version="1.0" encoding="UTF-8"?>	
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"	
	 xmlns="http://java.sun.com/xml/ns/javaee"	
	 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 	
	 http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"	
	 version="3.0">	
<display-name>labjsf</display-name>	
<servlet>	
<servlet-name>Faces Servlet</servlet-name>	
<servlet-class>javax.faces.webapp.FacesServlet</servletclass>	
<load-on-startup>1</load-on-startup>	
</servlet>	
<servlet-mapping>	
<servlet-name>Faces Servlet</servlet-name>	
<url-pattern>*.jsf</url-pattern>	
</servlet-mapping>	
... 	
</web-app>

web.xml
Outras configurações
<?xml version="1.0" encoding="UTF-8"?>	
<web-app ...>	
...	
	<context-param>	
	 	 <param-name>primefaces.THEME</param-name>	
	 	 <param-value>bootstrap</param-value>	
	 </context-param>	
	 	
	 <welcome-file-list>	
	 	 <welcome-file>index.jsf</welcome-file>	
	 </welcome-file-list>	
!

	 <session-config>	
	 	 <session-timeout>30</session-timeout>	
	 </session-config>	
</web-app>

web.xml
<?xml version='1.0' encoding='UTF-8' ?>	
<!DOCTYPE html >	
<html xmlns=“http://www.w3.org/1999/xhtml”	
xmlns:ui=“http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"	
xmlns:f=“http://java.sun.com/jsf/core" >	
<f:view locale="en">	
	 <h:head>	
	 	 <title>JSF</title>	
	 	 <h:outputScript library="javax.faces" name="jsf.js" target="head" />	
	 </h:head>	
	 <h:body>	
	 	 <h4>JSF</h4>	
	 	 <h:form id="jsfForm">	
	 	 	 <h:inputText id="nome" value="#{mainController.nome}" />	
	 	 	 <h:commandButton value="Exibir">	
	 	 	 	 <f:ajax execute="nome" render=":jsfForm:nameGroup" />	
	 	 	 </h:commandButton>	
	 	 	 <br />	
	 	 	 <h:panelGroup id="nameGroup">	
	 	 	 	 <h:outputText value="Oi! #{mainController.nome}!!"	
	 	 	 	 	 rendered="#{not empty mainController.nome}" />	
	 	 	 </h:panelGroup>	
	 	 </h:form>	

!
	 </h:body>	
</f:view>	
</html>

index.xhtml
@ManagedBean	
@ViewScoped	
public class MainController implements Serializable {	
!

	 private String nome;	
!
!

	 public String getNome() {	
	 	 return nome;	
	 }	
!

	 public void setNome(String nome) {	
	 	 this.nome = nome;	
	 }	
!

}

br.com.mariojp.view.MainController.java
<?xml version='1.0' encoding='UTF-8' ?>	
<!DOCTYPE html >	
<html xmlns="http://www.w3.org/1999/xhtml"	
	 xmlns:ui="http://java.sun.com/jsf/facelets"	
	 xmlns:h="http://java.sun.com/jsf/html"	
	 xmlns:f="http://java.sun.com/jsf/core"	
	 xmlns:p="http://primefaces.org/ui">	
<f:view locale="en">	
	 <h:head>	
	 	 <title>PrimeFaces</title>	
	 	 <h:outputScript library="javax.faces" name="jsf.js" target="head" />	
	 </h:head>	
	 <h:body>	
	 	 <h4>PrimeFaces</h4>	
	 	 <h:form id="jsfForm">	
	 	 	 <p:inputText id="nome" value="#{mainController.nome}" >	
	 	 	 	 <p:ajax event="keyup" process="@this" update=":jsfForm:nameGroup" />	
	 	 	 </p:inputText>	
	 	 	 <br />	
	 	 	 <h:panelGroup id="nameGroup">	
	 	 	 	 <h:outputText value="OI! #{mainController.nome}!!"	
	 	 	 	 	 rendered="#{not empty mainController.nome}" />	
	 	 	 </h:panelGroup>	
	 	 </h:form>	
	 </h:body>	
</f:view>	
</html>	

index2.xhtml
@ManagedBean	
@SessionScoped	
public class LoginController implements Serializable

{	

!
	
	
	

private static final long serialVersionUID = 1L;	
private String usuario;	
private String senha;	

!
	
	
	

public String getUsuario() {	
	 return usuario;	
}	

!
	
	
	

public void setUsuario(String usuario) {	
	 this.usuario = usuario;	
}	

!
	
	
	

public String getSenha() {	
	 return senha;	
}	

!
	
	
	

public void setSenha(String senha) {	
	 this.senha = senha;	
}	

!
	
	
	

!
}	

public String autenticar() {
	 return "home"; 	
} 	

	

LoginController.java
<?xml version='1.0' encoding='UTF-8' ?>	
<!DOCTYPE html >	
<html xmlns="http://www.w3.org/1999/xhtml"	
	
xmlns:ui="http://java.sun.com/jsf/facelets"	
	
xmlns:h="http://java.sun.com/jsf/html"	
	
xmlns:f="http://java.sun.com/jsf/core"	
	
xmlns:p="http://primefaces.org/ui">	
<f:view locale="en">	
	
<h:head>	
	
	
<title>Login</title>	
	
	
<h:outputScript library="javax.faces" name="jsf.js" target="head" />	
	
</h:head>	
	
<h:body>	
	
	
<h4>PrimeFaces</h4>	 	
	
	
	
<h:form id="jsfForm">	
	
	
	
<p:panel id="panel" header="Login">	
	
	
	
	
<h:panelGrid columns="3">	
	
	
	
	
	
<h:outputLabel for="usuario" value="Usuario: *" />	
	
	
	
	
	
<p:inputText id="usuario" value=“#{loginController.usuario}" required="true"
label="Usuario">	
	
	
	
	
	
	
<f:validateLength minimum="2" />	
	
	
	
	
	
</p:inputText>	
	
	
	
	
	
<p:message for="usuario" />	
	
	
	
	
	
<h:outputLabel for="senha" value="Senha: *" />	
	
	
	
	
	
<p:password id="senha" value="#{loginController.senha}"	
	
	
required="true" label="Senha">	
	
	
	
	
	
</p:password>	
	
	
	
	
	
<p:message for="senha" />	
	
	
	
	
</h:panelGrid>	
	
	
	
</p:panel>	
	
	
	
<p:commandButton value="Enviar" id="ajax" update="panel"	
	
	
	
	
action="#{loginController.autenticar}" />	
	
	
</h:form>	
	
</h:body>	
</f:view>	
</html>

t
h

l
m

lo

.x
in
g
<?xml version='1.0' encoding='UTF-8' ?>	
<!DOCTYPE html >	
<html xmlns="http://www.w3.org/1999/xhtml"	
	 xmlns:ui="http://java.sun.com/jsf/facelets"	
	 xmlns:h="http://java.sun.com/jsf/html"	
	 xmlns:f="http://java.sun.com/jsf/core"	
	 xmlns:p="http://primefaces.org/ui">	
<f:view locale="en">	
	 <h:head>	
	 	 <title>Login</title>	
	 	 <h:outputScript library="javax.faces" name="jsf.js" target="head"
/>	
	 </h:head>	
	 <h:body>	
	 	 <h4>PrimeFaces</h4>	
	 	 <h:form id="jsfForm">	
	 	 	 <h:outputLabel value="#{loginController.usuario}" />	
	 	 </h:form>	
	 </h:body>	
</f:view>	
</html>

m
o
h

.x
e

l
tm
h
Esta obra está licenciada sob a licença Creative Commons
Atribuição-CompartilhaIgual 3.0 Não Adaptada. Para ver uma cópia
desta licença, visite http://creativecommons.org/licenses/by-sa/3.0/.
Java web
Mario Jorge Pereira
Como me encontrar?
http://www.mariojp.com.br
twitter.com/@mariojp
mariojp@gmail.com

More Related Content

What's hot

Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/ServletSunil OS
 
JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)Talha Ocakçı
 
JSF Component Behaviors
JSF Component BehaviorsJSF Component Behaviors
JSF Component BehaviorsAndy Schwartz
 
Resthub framework presentation
Resthub framework presentationResthub framework presentation
Resthub framework presentationSébastien Deleuze
 
1 java servlets and jsp
1   java servlets and jsp1   java servlets and jsp
1 java servlets and jspAnkit Minocha
 
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
 
JavaFX – 10 things I love about you
JavaFX – 10 things I love about youJavaFX – 10 things I love about you
JavaFX – 10 things I love about youAlexander Casall
 
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
Html servlet example
Html   servlet exampleHtml   servlet example
Html servlet examplervpprash
 
Spring Framework - Web Flow
Spring Framework - Web FlowSpring Framework - Web Flow
Spring Framework - Web FlowDzmitry Naskou
 
A Complete Tour of JSF 2
A Complete Tour of JSF 2A Complete Tour of JSF 2
A Complete Tour of JSF 2Jim Driscoll
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriverRajathi-QA
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOPDzmitry Naskou
 
Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course JavaEE Trainers
 

What's hot (20)

Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
 
JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)
 
JSF Component Behaviors
JSF Component BehaviorsJSF Component Behaviors
JSF Component Behaviors
 
Resthub framework presentation
Resthub framework presentationResthub framework presentation
Resthub framework presentation
 
1 java servlets and jsp
1   java servlets and jsp1   java servlets and jsp
1 java servlets and jsp
 
Jsp element
Jsp elementJsp element
Jsp element
 
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
 
Resthub lyonjug
Resthub lyonjugResthub lyonjug
Resthub lyonjug
 
JavaFX – 10 things I love about you
JavaFX – 10 things I love about youJavaFX – 10 things I love about you
JavaFX – 10 things I love about you
 
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
 
Html servlet example
Html   servlet exampleHtml   servlet example
Html servlet example
 
Tomcat + other things
Tomcat + other thingsTomcat + other things
Tomcat + other things
 
Spring Framework - Web Flow
Spring Framework - Web FlowSpring Framework - Web Flow
Spring Framework - Web Flow
 
Wt unit 3
Wt unit 3 Wt unit 3
Wt unit 3
 
A Complete Tour of JSF 2
A Complete Tour of JSF 2A Complete Tour of JSF 2
A Complete Tour of JSF 2
 
Cis 274 intro
Cis 274   introCis 274   intro
Cis 274 intro
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriver
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
 
Implicit object.pptx
Implicit object.pptxImplicit object.pptx
Implicit object.pptx
 
Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course
 

Similar to Java Server Faces

JavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオンJavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオンharuki ueno
 
Ajax, JSF, Facelets, Eclipse & Maven tutorials
Ajax, JSF, Facelets, Eclipse & Maven tutorialsAjax, JSF, Facelets, Eclipse & Maven tutorials
Ajax, JSF, Facelets, Eclipse & Maven tutorialsRaghavan Mohan
 
Pom configuration java xml
Pom configuration java xmlPom configuration java xml
Pom configuration java xmlakmini
 
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
 
Automation Frame works Instruction Sheet
Automation Frame works Instruction SheetAutomation Frame works Instruction Sheet
Automation Frame works Instruction SheetvodQA
 
Spring Boot and JHipster
Spring Boot and JHipsterSpring Boot and JHipster
Spring Boot and JHipsterEueung Mulyana
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemAndres Almiray
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 
Spring into rails
Spring into railsSpring into rails
Spring into railsHiro Asari
 
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
 
Training in Android with Maven
Training in Android with MavenTraining in Android with Maven
Training in Android with MavenArcadian Learning
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 

Similar to Java Server Faces (20)

JavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオンJavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオン
 
Ajax, JSF, Facelets, Eclipse & Maven tutorials
Ajax, JSF, Facelets, Eclipse & Maven tutorialsAjax, JSF, Facelets, Eclipse & Maven tutorials
Ajax, JSF, Facelets, Eclipse & Maven tutorials
 
Jsf
JsfJsf
Jsf
 
Pom configuration java xml
Pom configuration java xmlPom configuration java xml
Pom configuration java xml
 
Pom
PomPom
Pom
 
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
 
Taking your Web App for a walk
Taking your Web App for a walkTaking your Web App for a walk
Taking your Web App for a walk
 
Automation Frame works Instruction Sheet
Automation Frame works Instruction SheetAutomation Frame works Instruction Sheet
Automation Frame works Instruction Sheet
 
Spring Boot and JHipster
Spring Boot and JHipsterSpring Boot and JHipster
Spring Boot and JHipster
 
Symfony2 revealed
Symfony2 revealedSymfony2 revealed
Symfony2 revealed
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX Ecosystem
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
Spring into rails
Spring into railsSpring into rails
Spring into rails
 
JAX-WS Basics
JAX-WS BasicsJAX-WS Basics
JAX-WS Basics
 
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
 
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
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
Maven in Mule
Maven in MuleMaven in Mule
Maven in Mule
 
Training in Android with Maven
Training in Android with MavenTraining in Android with Maven
Training in Android with Maven
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 

More from Mario Jorge Pereira (20)

Educacao e Inteligencia Artificial Generativa
Educacao e Inteligencia Artificial GenerativaEducacao e Inteligencia Artificial Generativa
Educacao e Inteligencia Artificial Generativa
 
Labs Jogos Java
Labs Jogos JavaLabs Jogos Java
Labs Jogos Java
 
Java www
Java wwwJava www
Java www
 
Html
HtmlHtml
Html
 
HTTP
HTTPHTTP
HTTP
 
Lógica de Programação e Algoritmos
Lógica de Programação e AlgoritmosLógica de Programação e Algoritmos
Lógica de Programação e Algoritmos
 
Guia rapido java v2
Guia rapido java v2Guia rapido java v2
Guia rapido java v2
 
Guia Rápido de Referência Java
Guia Rápido de Referência JavaGuia Rápido de Referência Java
Guia Rápido de Referência Java
 
Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015 Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015
 
Java Nuvem Appengine
Java Nuvem AppengineJava Nuvem Appengine
Java Nuvem Appengine
 
Mini curso Android
Mini curso AndroidMini curso Android
Mini curso Android
 
Minicurso Android
Minicurso AndroidMinicurso Android
Minicurso Android
 
Android, por onde começar?
Android, por onde começar?Android, por onde começar?
Android, por onde começar?
 
Hands-On Java web passando por Servlets, JSP, JSTL, JDBC, Hibernate, DAO, MV...
Hands-On Java web passando por  Servlets, JSP, JSTL, JDBC, Hibernate, DAO, MV...Hands-On Java web passando por  Servlets, JSP, JSTL, JDBC, Hibernate, DAO, MV...
Hands-On Java web passando por Servlets, JSP, JSTL, JDBC, Hibernate, DAO, MV...
 
Android e Cloud Computing
Android e Cloud ComputingAndroid e Cloud Computing
Android e Cloud Computing
 
Threads
ThreadsThreads
Threads
 
RMI (Remote Method Invocation)
RMI (Remote Method Invocation) RMI (Remote Method Invocation)
RMI (Remote Method Invocation)
 
Socket
SocketSocket
Socket
 
Java e Cloud Computing
Java e Cloud ComputingJava e Cloud Computing
Java e Cloud Computing
 
GUI - Eventos
GUI - EventosGUI - Eventos
GUI - Eventos
 

Recently uploaded

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 

Recently uploaded (20)

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 

Java Server Faces

  • 1. Java Server Faces 2.2 PrimeFaces 4.0 Servlet 3.0 Maven
  • 2.
  • 5. Agenda • Maven • Servlet 3.0 • Java Server Faces - JSF 2.2 • PrimeFaces - Prime 4.0
  • 6. File > New > Other…
  • 9. Project > Properties > Project Facets
  • 11. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>br.com.mariojp</groupId> <artifactId>labjsf</artifactId> <version>0.0.1-SNAPSHOT</version> <name>labjsf</name> <packaging>war</packaging> </project> pom.xml
  • 12. adicionando jsf 2.2 e servlet 3.0 <project ... > ... <dependencies> <dependency> <groupId>com.sun.faces</groupId> <artifactId>jsf-api</artifactId> <version>2.2.2</version> </dependency> <dependency> <groupId>com.sun.faces</groupId> <artifactId>jsf-impl</artifactId> <version>2.2.2</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.0.1</version> </dependency> </dependencies> </project> pom.xml
  • 13. adicionando commons-fileupload <project ... > ... <dependencies> ... <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3</version> </dependency> </dependencies> </project> pom.xml
  • 14. adicionando primefaces <project ... > ... <dependencies> ... <dependency> <groupId>org.primefaces.themes</groupId> <artifactId>all-themes</artifactId> <version>1.0.10</version> </dependency> <dependency> <groupId>org.primefaces</groupId> <artifactId>primefaces</artifactId> <version>4.0</version> </dependency> <repositories> <repository> <id>prime-repo</id> <name>PrimeFaces Maven Repository</name> <url>http://repository.primefaces.org</url> <layout>default</layout> </repository> </repositories> </project> pom.xml
  • 15. Mapeando o Servlet do JSF <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <display-name>labjsf</display-name> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servletclass> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping> ... </web-app> web.xml
  • 16. Outras configurações <?xml version="1.0" encoding="UTF-8"?> <web-app ...> ... <context-param> <param-name>primefaces.THEME</param-name> <param-value>bootstrap</param-value> </context-param> <welcome-file-list> <welcome-file>index.jsf</welcome-file> </welcome-file-list> ! <session-config> <session-timeout>30</session-timeout> </session-config> </web-app> web.xml
  • 17. <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html > <html xmlns=“http://www.w3.org/1999/xhtml” xmlns:ui=“http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f=“http://java.sun.com/jsf/core" > <f:view locale="en"> <h:head> <title>JSF</title> <h:outputScript library="javax.faces" name="jsf.js" target="head" /> </h:head> <h:body> <h4>JSF</h4> <h:form id="jsfForm"> <h:inputText id="nome" value="#{mainController.nome}" /> <h:commandButton value="Exibir"> <f:ajax execute="nome" render=":jsfForm:nameGroup" /> </h:commandButton> <br /> <h:panelGroup id="nameGroup"> <h:outputText value="Oi! #{mainController.nome}!!" rendered="#{not empty mainController.nome}" /> </h:panelGroup> </h:form> ! </h:body> </f:view> </html> index.xhtml
  • 18. @ManagedBean @ViewScoped public class MainController implements Serializable { ! private String nome; ! ! public String getNome() { return nome; } ! public void setNome(String nome) { this.nome = nome; } ! } br.com.mariojp.view.MainController.java
  • 19. <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html > <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"> <f:view locale="en"> <h:head> <title>PrimeFaces</title> <h:outputScript library="javax.faces" name="jsf.js" target="head" /> </h:head> <h:body> <h4>PrimeFaces</h4> <h:form id="jsfForm"> <p:inputText id="nome" value="#{mainController.nome}" > <p:ajax event="keyup" process="@this" update=":jsfForm:nameGroup" /> </p:inputText> <br /> <h:panelGroup id="nameGroup"> <h:outputText value="OI! #{mainController.nome}!!" rendered="#{not empty mainController.nome}" /> </h:panelGroup> </h:form> </h:body> </f:view> </html> index2.xhtml
  • 20. @ManagedBean @SessionScoped public class LoginController implements Serializable { ! private static final long serialVersionUID = 1L; private String usuario; private String senha; ! public String getUsuario() { return usuario; } ! public void setUsuario(String usuario) { this.usuario = usuario; } ! public String getSenha() { return senha; } ! public void setSenha(String senha) { this.senha = senha; } ! ! } public String autenticar() { return "home"; } LoginController.java
  • 21. <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html > <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"> <f:view locale="en"> <h:head> <title>Login</title> <h:outputScript library="javax.faces" name="jsf.js" target="head" /> </h:head> <h:body> <h4>PrimeFaces</h4> <h:form id="jsfForm"> <p:panel id="panel" header="Login"> <h:panelGrid columns="3"> <h:outputLabel for="usuario" value="Usuario: *" /> <p:inputText id="usuario" value=“#{loginController.usuario}" required="true" label="Usuario"> <f:validateLength minimum="2" /> </p:inputText> <p:message for="usuario" /> <h:outputLabel for="senha" value="Senha: *" /> <p:password id="senha" value="#{loginController.senha}" required="true" label="Senha"> </p:password> <p:message for="senha" /> </h:panelGrid> </p:panel> <p:commandButton value="Enviar" id="ajax" update="panel" action="#{loginController.autenticar}" /> </h:form> </h:body> </f:view> </html> t h l m lo .x in g
  • 22. <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html > <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"> <f:view locale="en"> <h:head> <title>Login</title> <h:outputScript library="javax.faces" name="jsf.js" target="head" /> </h:head> <h:body> <h4>PrimeFaces</h4> <h:form id="jsfForm"> <h:outputLabel value="#{loginController.usuario}" /> </h:form> </h:body> </f:view> </html> m o h .x e l tm h
  • 23.
  • 24. Esta obra está licenciada sob a licença Creative Commons Atribuição-CompartilhaIgual 3.0 Não Adaptada. Para ver uma cópia desta licença, visite http://creativecommons.org/licenses/by-sa/3.0/.
  • 25. Java web Mario Jorge Pereira Como me encontrar? http://www.mariojp.com.br twitter.com/@mariojp mariojp@gmail.com