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:schemaLo...
adicionando jsf 2.2 e servlet 3.0

<project ... >	
...	
	 <dependencies>	
	 	 <dependency>	
	 	 	 <groupId>com.sun.faces</...
adicionando commons-fileupload

<project ... >	
...	
	 <dependencies>	
...	
	 	 <dependency>	
	 	 	 <groupId>commons-fileup...
adicionando primefaces

<project ... >	
...	
	 <dependencies>	
...	
	 	 <dependency>	
	 	 	 <groupId>org.primefaces.themes...
Mapeando o Servlet do JSF
<?xml version="1.0" encoding="UTF-8"?>	
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-ins...
Outras configurações
<?xml version="1.0" encoding="UTF-8"?>	
<web-app ...>	
...	
	<context-param>	
	 	 <param-name>primefac...
<?xml version='1.0' encoding='UTF-8' ?>	
<!DOCTYPE html >	
<html xmlns=“http://www.w3.org/1999/xhtml”	
xmlns:ui=“http://ja...
@ManagedBean	
@ViewScoped	
public class MainController implements Serializable {	
!

	 private String nome;	
!
!

	 public...
<?xml version='1.0' encoding='UTF-8' ?>	
<!DOCTYPE html >	
<html xmlns="http://www.w3.org/1999/xhtml"	
	 xmlns:ui="http://...
@ManagedBean	
@SessionScoped	
public class LoginController implements Serializable

{	

!
	
	
	

private static final long...
<?xml version='1.0' encoding='UTF-8' ?>	
<!DOCTYPE html >	
<html xmlns="http://www.w3.org/1999/xhtml"	
	
xmlns:ui="http://...
<?xml version='1.0' encoding='UTF-8' ?>	
<!DOCTYPE html >	
<html xmlns="http://www.w3.org/1999/xhtml"	
	 xmlns:ui="http://...
Esta obra está licenciada sob a licença Creative Commons
Atribuição-CompartilhaIgual 3.0 Não Adaptada. Para ver uma cópia
...
Java web
Mario Jorge Pereira
Como me encontrar?
http://www.mariojp.com.br
twitter.com/@mariojp
mariojp@gmail.com
Java Server Faces
Java Server Faces
Upcoming SlideShare
Loading in...5
×

Java Server Faces

15,916

Published on

Desenvolvimento de uma aplicação com maven utilizando JSF 2.2, Prime Faces 4.0 e Servlets 3.0.

Published in: Education, Technology
0 Comments
8 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
15,916
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
58
Comments
0
Likes
8
Embeds 0
No embeds

No notes for slide

Java Server Faces

  1. 1. Java Server Faces 2.2 PrimeFaces 4.0 Servlet 3.0 Maven
  2. 2. java web Mario Jorge Pereira
  3. 3. 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
  4. 4. Agenda • Maven • Servlet 3.0 • Java Server Faces - JSF 2.2 • PrimeFaces - Prime 4.0
  5. 5. File > New > Other…
  6. 6. Skip archetype selection
  7. 7. br.com.mariojp.labjsf
  8. 8. Project > Properties > Project Facets
  9. 9. Runtime são Ver et e Fac
  10. 10. <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
  11. 11. 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
  12. 12. adicionando commons-fileupload <project ... > ... <dependencies> ... <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3</version> </dependency> </dependencies> </project> pom.xml
  13. 13. 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
  14. 14. 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
  15. 15. 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
  16. 16. <?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
  17. 17. @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
  18. 18. <?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
  19. 19. @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
  20. 20. <?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
  21. 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"> <h:outputLabel value="#{loginController.usuario}" /> </h:form> </h:body> </f:view> </html> m o h .x e l tm h
  22. 22. 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/.
  23. 23. Java web Mario Jorge Pereira Como me encontrar? http://www.mariojp.com.br twitter.com/@mariojp mariojp@gmail.com
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×