Sorgenti del corso#
Table of Contents
- Sorgenti del corso
- Parte 1
- index.html (v1)
- list.xhtml (v1)
- Parte 2
- masterLayout.xhtml (v1)
- index.xhtml (v2)
- list.xhtml (v2)
- style.css (v1)
- Parte 3
- ApplicationController.java
- marsterLayout.xhtml (porzione)
- index.xhtml (porzione)
- Parte 4
- Camera.java
- Prenotazione.java
- list.xhtml
- tabellaCamere.xhtml
- intestazioneCamere.xhtml
- intestazioneCamere.xhtml (porzione)
- intestazioneCamere.xhtml (porzione)
Parte 1#
index.html (v1)#
<?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>Pagina Iniziale</title>
</h:head>
<h:body>
<h:form>
<h:commandButton action="views/list" value="Entra"/>
</h:form>
</h:body>
</html>
list.xhtml (v1)#
<!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:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>Pagina Iniziale</title>
</h:head>
<h:body>
<h1><h:outputText value="Hello World"/></h1>
</h:body>
</html>
Parte 2#
![]() |
masterLayout.xhtml (v1)#
<!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:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>Pagina Iniziale</title>
</h:head>
<h:body>
<div id="header">
<h:graphicImage library="images" name="header_logo.gif"/>
JSF Sample Application
</div>
<h:form>
<ui:insert name="content"/>
</h:form>
</h:body>
<h:outputStylesheet library="css" name="style.css"/>
</html>
index.xhtml (v2)#
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
template="/template/masterLayout.xhtml">
<ui:define name="content">
<h:commandButton action="views/list" value="Entra"/>
</ui:define>
</ui:composition>
list.xhtml (v2)#
<ui:composition
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
template="/template/masterLayout.xhtml">
<ui:define name="content">
<h1>
<h:outputText value="Hello World!!!"/>
</h1>
</ui:define>
</ui:composition>
style.css (v1)#
body {
font-family: Verdana,Arial,Helvetica,sans-serif;
font-size: 11px;
margin: 0px;
padding: 0px;
}
#header {
width: 100%;
margin-bottom: 10px;
border-bottom: 2px solid #999;
color:#000066;
font-size: 30px;
}
Parte 3#
ApplicationController.java#
package corsojsf.managedbeans;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;
@ManagedBean
@RequestScoped
public class ApplicationController {
private int random=-1;
public String paginaLista(){
return "views/list";
}
public int getNumeroRandom(){
if (random==-1)
random= (int)(Math.random()*100);
return random;
}
}
marsterLayout.xhtml (porzione)#
[...]
JSF Sample Application #{applicationController.numeroRandom}
[...]
index.xhtml (porzione)#
[...]
<ui:define name="content">
<h:commandButton action="#{applicationController.paginaLista}" value="Entra"/>
</ui:define>
[...]
Parte 4#
Camera.java#
package corsojsf.model;
import java.math.BigDecimal;
public class Camera {
private String nome;
private Integer numeroPosti;
private BigDecimal prezzo;
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public Integer getNumeroPosti() {
return numeroPosti;
}
public void setNumeroPosti(Integer numeroPosti) {
this.numeroPosti = numeroPosti;
}
public BigDecimal getPrezzo() {
return prezzo;
}
public void setPrezzo(BigDecimal prezzo) {
this.prezzo = prezzo;
}
}
Prenotazione.java#
package corsojsf.model;
import java.util.Date;
public class Prenotazione {
private String cliente;
private Date dataInizio;
private Date dataFIne;
private Camera camera;
public Camera getCamera() {
return camera;
}
public void setCamera(Camera camera) {
this.camera = camera;
}
public String getCliente() {
return cliente;
}
public void setCliente(String cliente) {
this.cliente = cliente;
}
public Date getDataFIne() {
return dataFIne;
}
public void setDataFIne(Date dataFIne) {
this.dataFIne = dataFIne;
}
public Date getDataInizio() {
return dataInizio;
}
public void setDataInizio(Date dataInizio) {
this.dataInizio = dataInizio;
}
}
list.xhtml#
<ui:composition
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
template="/template/masterLayout.xhtml"
xmlns:f="http://java.sun.com/jsf/core">
<ui:define name="content">
<ui:include src="/sections/list/intestazioneCamere.xhtml"/>
<ui:include src="/sections/list/tabellaCamere.xhtml"/>
</ui:define>
</ui:composition>
tabellaCamere.xhtml#
<ui:composition
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:dataTable styleClass="lista" value="#{listController.camere}" var="camera">
<h:column>
<f:facet name="header">
<h:outputText value="nome"/>
</f:facet>
<h:outputText value="#{camera.nome}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="n.posti"/>
</f:facet>
<h:outputText value="#{camera.numeroPosti}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="prezzo"/>
</f:facet>
<h:outputText value="#{camera.prezzo}"/>
</h:column>
<h:column>
<h:outputLink value="Edit"/>
#160;
<h:outputLink value="Del"/>
</h:column>
</h:dataTable>
</ui:composition>
intestazioneCamere.xhtml#
<ui:composition
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h3>
<h:outputText value="Lista Camere"/>
</h3>
<h:commandLink action="#{listController.nuovaCamera}" value="Nuova"/>
</ui:composition>
intestazioneCamere.xhtml (porzione)#
[...]
<h3>
<h:outputText value="Lista Camere"/>
</h3>
<h3>
<h:outputText style="display:block" value="Nessuna camera trovata"
rendered="#{empty listController.camere}"/>
</h3>
[...]
intestazioneCamere.xhtml (porzione)#
[...]
<h:dataTable styleClass="lista" value="#{listController.camere}"
var="camera" rendered="#{!empty listController.camere}">
[...]
Add new attachment
Only authorized users are allowed to upload new attachments.
List of attachments
| Kind | Attachment Name | Size | Version | Date Modified | Author | Change note |
|---|---|---|---|---|---|---|
ppt |
Corso JSF.ppt | 783.9 kB | 1 | 02-Sep-2010 07:52 | m.sanfilippo | |
zip |
SmeaCrud-src.zip | 31.7 kB | 1 | 31-Aug-2010 16:02 | Administrator | |
war |
SmeaCrud.war | 30.9 kB | 1 | 31-Aug-2010 16:02 | Administrator | |
gif |
jsf.gif | 5.7 kB | 1 | 23-Aug-2010 19:42 | Administrator |
«
This particular version was published on 24-Aug-2010 12:05 by Administrator.
