Ejemplo n.º 1
0
  public void loadLingue() {

    if (addettoId == null) return;

    LinguaConosciutaService ls = ServiceFactory.createService("LinguaConosciuta");
    listLingue = ls.listByAddetto(addettoId);
  }
Ejemplo n.º 2
0
  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.
    //
    LinguaConosciutaService ls = ServiceFactory.createService("LinguaConosciuta");
    selected = ls.retrieveDeep(selected.getId());

    id = selected.getId();
    codiceLingua = selected.getLingua() != null ? selected.getLingua().getId() : null;
    codiceLivelloLingua =
        selected.getLivelloLingua() != null ? selected.getLivelloLingua().getId() : null;
    note = selected.getNote();
  }
Ejemplo n.º 3
0
  public void doDelete() {

    // Create service to delete record.
    //
    LinguaConosciutaService ls = ServiceFactory.createService("LinguaConosciuta");

    try {
      ls.delete(selected.getId());

      // Everything went fine.
      //
      FacesMessage message =
          new FacesMessage(
              FacesMessage.SEVERITY_INFO,
              "Successo",
              "L'eliminazione del record selezionato si è conclusa con successo.");
      FacesContext.getCurrentInstance().addMessage(null, message);

      // Reset selection.
      //
      selected = null;

      // Refresh list.
      //
      loadLingue();

    } catch (Exception e) {

      logger.warn("Exception caught while deleting entity.", e);

      FacesMessage message =
          new FacesMessage(
              FacesMessage.SEVERITY_ERROR,
              "Errore di sistema",
              "Si è verificato un errore in fase di eliminazione del record.");
      FacesContext.getCurrentInstance().addMessage(null, message);
    }
  }
Ejemplo n.º 4
0
  public void doSave() {

    // Apply form-level validations.
    //
    if (!formValidations()) return;

    // Create service to persist data.
    //
    LinguaConosciutaService ls = ServiceFactory.createService("LinguaConosciuta");

    try {
      LinguaConosciuta entity = null;

      // If the record already exists, just update it.
      //
      if (id != null) {

        entity = ls.update(id, codiceLingua, codiceLivelloLingua, note);

        logger.debug("Entity successfully updated.");
      }

      // Otherwise create a new record.
      //
      else {

        entity = ls.create(addettoId, codiceLingua, codiceLivelloLingua, note);
        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.
      //
      loadLingue();

      // 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);
    }
  }