File ContactsPage.xhtml
codice:
<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Contacts</title>
<p:resources />
<style>
form{font-size:12px;}
</style>
</h:head>
<h:body>
<h:form>
<p:spacer height="10"></p:spacer>
<p:graphicImage value="Contacts" fontName="Tahoma" fontStyle="bold" fontSize="24"/>
<p:spacer height="10"/>
<p:panel header="Contacts">
<p:dataTable var="contact" value="#{contactsBean.contacts}" id="tbl"
selection="#{contactsBean.contact}" selectionMode="single"
update="updForm:updDisplay" onselectComplete="updDialog.show()"
paginator="true" rows="5">
<p:column>
<f:facet name="header">
<h:outputText value="Nome" />
</f:facet>
<h:outputText value="#{contact.name}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Cognome" />
</f:facet>
<h:outputText value="#{contact.surname}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Telefono" />
</f:facet>
<h:outputText value="#{contact.telephone}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Professione" />
</f:facet>
<h:outputText value="#{contact.job}" />
</p:column>
<f:facet name="footer">
<h:panelGroup>
<h:commandLink>
<p:graphicImage value="/images/excel.png" style="border:none" />
<p:dataExporter type="xls" target="tbl" fileName="contacts"
pageOnly="true" />
</h:commandLink>
<h:commandLink>
<p:graphicImage value="/images/pdf.png" style="border:none" />
<p:dataExporter type="pdf" target="tbl" fileName="contacts"
pageOnly="true" />
</h:commandLink>
<h:commandLink>
<p:graphicImage value="/images/csv.png" style="border:none" />
<p:dataExporter type="csv" target="tbl" fileName="contacts"
pageOnly="true" />
</h:commandLink>
<h:commandLink>
<p:graphicImage value="/images/xml.png" style="border:none" />
<p:dataExporter type="xml" target="tbl" fileName="contacts"
pageOnly="true" />
</h:commandLink>
</h:panelGroup>
</f:facet>
</p:dataTable>
</p:panel>
</h:form>
<p:spacer height="10" />
<h:form id="updForm">
<h:panelGrid columns="2">
<p:commandButton oncomplete="newDialog.show()" value="Nuovo Contatto"
update="newDisplay" ajax="true" />
<p:themeSwitcher initialText="Cambia tema"></p:themeSwitcher>
</h:panelGrid>
<p:dialog widgetVar="updDialog" header="Contatto" width="430"
height="220" modal="true">
<p:outputPanel id="updDisplay">
<h:inputHidden value="#{contactsBean.contact.id}" />
<h:panelGrid columns="2">
<h:outputLabel value="Nome" />
<p:inputText value="#{contactsBean.contact.name}"></p:inputText>
<h:outputLabel value="Cognome" />
<p:inputText value="#{contactsBean.contact.surname}"></p:inputText>
<h:outputLabel value="Telefono" />
<p:inputText value="#{contactsBean.contact.telephone}"></p:inputText>
<h:outputLabel value="Professione" />
<p:inputText value="#{contactsBean.contact.job}"></p:inputText>
</h:panelGrid>
<p:commandButton value="Aggiorna" ajax="true"
actionListener="#{contactsBean.aggiorna}" update="tbl,growl"
onclick="updDialog.close()"></p:commandButton>
<p:commandButton value="Elimina" ajax="true"
actionListener="#{contactsBean.elimina}" update="tbl,growl"
onclick="updDialog.close()"></p:commandButton>
<p:growl id="growl" showDetail="true" />
</p:outputPanel>
</p:dialog>
</h:form>
<h:form>
<p:dialog widgetVar="newDialog" header="Inserisci Contatto"
width="430" height="220" modal="true">
<p:outputPanel id="newDisplay">
<h:panelGrid columns="2">
<h:outputLabel value="Nome" />
<p:inputText value="#{contactsBean.contact.name}"></p:inputText>
<h:outputLabel value="Cognome" />
<p:inputText value="#{contactsBean.contact.surname}"></p:inputText>
<h:outputLabel value="Telefono" />
<p:inputText value="#{contactsBean.contact.telephone}"></p:inputText>
<h:outputLabel value="Professione" />
<p:inputText value="#{contactsBean.contact.job}"></p:inputText>
</h:panelGrid>
<p:commandButton value="Salva" ajax="true"
actionListener="#{contactsBean.salva}" update="tbl"
onclick="newDialog.close()"></p:commandButton>
</p:outputPanel>
</p:dialog>
</h:form>
</h:body>
</html>