SlideShare une entreprise Scribd logo
1  sur  25
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

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
 

Tendances (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
 

Similaire à 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
 

Similaire à 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
 

Plus de 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
 

Dernier

2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 

Dernier (20)

2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 

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