| At line 476 added 35 lines |
| %%tab-Parte7 |
| !!Parte 7 |
|
| !prenotazione.xhtml |
| %%prettify |
| {{{ |
| <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"> |
| <h:panelGrid columns="2"> |
| <h:outputLabel for="camera" value="camera"/> |
| <h:selectOneMenu id="camera" value="#{listController.prenotazione.camera}"> |
| <f:selectItems value="#{listController.camere}" var="camera" itemValue="#{camera}" itemLabel="#{camera.nome}"/> |
| </h:selectOneMenu> |
| <h:outputLabel for="cliente" value="cliente"/> |
| <h:inputText id="cliente" value="#{listController.prenotazione.cliente}" required="true"> |
| </h:inputText> |
| <h:outputLabel for="dal" value="Dal"/> |
| <h:inputText id="dal" value="#{listController.prenotazione.dataInizio}" required="true"> |
| <f:convertDateTime pattern="yyyymmdd" /> |
| </h:inputText> |
| <h:outputLabel for="al" value="Al"/> |
| <h:inputText id="al" value="#{listController.prenotazione.dataFine}" required="true"> |
| <f:convertDateTime pattern="yyyymmdd" /> |
| </h:inputText> |
| <h:commandButton value="annulla" action="/views/list" immediate="true"/> |
| <h:commandButton value="salva" action="#{listController.salvaPrenotazione}"/> |
| </h:panelGrid> |
| </ui:define> |
| </ui:composition> |
| }}} |
| At line 512 added 43 lines |
|
|
| !CameraConverter.java |
| %%prettify |
| {{{ |
|
| package corsojsf.managedbeans; |
|
| import corsojsf.model.Camera; |
| import java.util.List; |
| import javax.faces.component.UIComponent; |
| import javax.faces.component.UISelectItems; |
| import javax.faces.context.FacesContext; |
| import javax.faces.convert.Converter; |
| import javax.faces.convert.ConverterException; |
| import javax.faces.convert.FacesConverter; |
|
| @FacesConverter(forClass=Camera.class) |
| public class CameraConverter implements Converter { |
|
| @Override |
| public Object getAsObject(FacesContext context, UIComponent component, String value) { |
| List<Camera> items = (List<Camera>) ((UISelectItems) component.getChildren().get(0)).getValue(); |
| for (Camera camera : items) { |
| if (camera.getNome().equals(value)) { |
| return camera; |
| } |
| } |
| throw new ConverterException("Impossibile convertire " + value); |
| } |
|
| @Override |
| public String getAsString(FacesContext context, UIComponent component, Object value) { |
| if (value instanceof Camera) { |
| return ((Camera) value).getNome(); |
| } else { |
| throw new IllegalArgumentException("Impossibile convertire oggetti " + value.getClass().getCanonicalName()); |
| } |
| } |
| } |
|
|
| }}} |
| At line 557 added 45 lines |
| !ListController.java (porzione) |
| %%prettify |
| {{{ |
|
| [...] |
| public String nuovaPrenotazione() { |
| setPrenotazione(new Prenotazione()); |
| return "/views/prenotazione"; |
| } |
|
| public String modificaPrenotazione(Prenotazione prenotazione) { |
| setPrenotazione(prenotazione); |
| return "/views/prenotazione"; |
| } |
|
|
| public void eliminaPrenotazione(Prenotazione prenotazione) |
| { |
| getPrenotazioni().remove(prenotazione); |
| } |
|
| public String salvaPrenotazione() { |
| Prenotazione daSavlare = getPrenotazione(); |
| if (getPrenotazioni() == null) { |
| this.prenotazioni = new LinkedList<Prenotazione>(); |
| } |
| if (this.prenotazioni.contains(daSavlare)) { |
| getPrenotazioni().remove(daSavlare); |
| } |
| getPrenotazioni().add(daSavlare); |
| setPrenotazione(new Prenotazione()); |
| return "/views/list"; |
| } |
| [...] |
| |
| }}} |
| /% |
|
| /% |
|
|
|
| /% |
| /% |
|