public void startUpdate() { logger.debug("Entering startUpdate() method."); // Reloading the entity is required to be sure that the value has not changed since it was // read in the data table list of values. // ContrattoContattoService ccs = ServiceFactory.createService("ContrattoContatto"); selected = ccs.retrieveDeep(selected.getId()); id = selected.getId(); selectedContatto = selected.getContatto(); validoDa = selected.getValidoDa(); validoA = selected.getValidoA(); // Load list of available contatti records. // ContattoService cs = ServiceFactory.createService("Contatto"); listContattiDisponibili = cs.listDisponibiliPerContratto( dettaglioContrattoGenerale.getId(), selectedContatto.getId()); }
public void doSave() { // Apply form-level validations. // if (!formValidations()) return; // Create service to persist data. // ContrattoContattoService cs = ServiceFactory.createService("ContrattoContatto"); try { ContrattoContatto entity = null; // If the record already exists, just update it. // if (id != null) { entity = cs.update(id, selectedContatto.getId(), validoDa, validoA); logger.debug("Entity successfully updated."); } // Otherwise create a new record. // else { entity = cs.create( dettaglioContrattoGenerale.getId(), selectedContatto.getId(), validoDa, validoA); id = entity.getId(); logger.debug("Entity successfully created."); } // Everything went fine. // FacesMessage message = new FacesMessage( FacesMessage.SEVERITY_INFO, "Successo", "Il salvataggio dei dati si è concluso con successo."); FacesContext.getCurrentInstance().addMessage(null, message); // Refresh list. // loadContatti(); // Signal to modal dialog that everything went fine. // RequestContext.getCurrentInstance().addCallbackParam("ok", true); } catch (Exception e) { logger.warn("Exception caught while saving entity.", e); FacesMessage message = new FacesMessage( FacesMessage.SEVERITY_ERROR, "Errore di sistema", "Si è verificato un errore in fase di salvataggio del record."); FacesContext.getCurrentInstance().addMessage(null, message); } }