Пример #1
0
 public boolean eliminar() {
   boolean ok = false;
   RequestContext context = RequestContext.getCurrentInstance();
   FacesMessage fMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Aviso:", "eliminar: mbUpc");
   try {
     if (this.listaUpcs.size() > 2 && this.upc.isActual()) {
       fMsg.setSeverity(FacesMessage.SEVERITY_WARN);
       fMsg.setDetail("No se puede eliminar, cambie primero de actual");
     } else {
       this.dao = new DAOUpcs();
       this.dao.Eliminar(this.upc.getUpc());
       this.cargaListaUpcs();
       ok = true;
     }
   } catch (NamingException ex) {
     fMsg.setDetail(ex.getMessage());
   } catch (SQLException ex) {
     fMsg.setDetail(ex.getErrorCode() + " " + ex.getMessage());
   }
   if (!ok) {
     FacesContext.getCurrentInstance().addMessage(null, fMsg);
   }
   context.addCallbackParam("okUpc", ok);
   return ok;
 }
Пример #2
0
 public void cargarDetalles(int idZona, int idGrupo) {
   boolean ok = false;
   FacesMessage fMsg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Aviso:", "");
   if (this.periodo == null) {
     this.periodo = "1";
   }
   try {
     if (idZona == 0 || idGrupo == 0) {
       this.detalles = new ArrayList<ImpuestoDetalle>();
     } else {
       this.dao = new DAOImpuestosDetalle();
       this.detalles = this.dao.obtenerDetalles(idZona, idGrupo, this.periodo);
     }
     ok = true;
   } catch (SQLException ex) {
     fMsg.setSeverity(FacesMessage.SEVERITY_ERROR);
     fMsg.setDetail(ex.getErrorCode() + " " + ex.getMessage());
   } catch (NamingException ex) {
     fMsg.setSeverity(FacesMessage.SEVERITY_ERROR);
     fMsg.setDetail(ex.getMessage());
   }
   if (!ok) {
     FacesContext.getCurrentInstance().addMessage(null, fMsg);
   }
 }
Пример #3
0
 public boolean agregar() {
   boolean ok = false;
   FacesMessage fMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Aviso:", "agregar: mbUpc");
   //        RequestContext context = RequestContext.getCurrentInstance();
   try {
     if (this.upc.getUpc().equals("")) {
       fMsg.setSeverity(FacesMessage.SEVERITY_WARN);
       fMsg.setDetail("Se requiere un UPC !");
     } else {
       this.dao = new DAOUpcs();
       this.dao.agregar(this.upc);
       this.cargaListaUpcs();
       ok = true;
     }
   } catch (NamingException ex) {
     fMsg.setDetail(ex.getMessage());
   } catch (SQLException ex) {
     fMsg.setDetail(ex.getErrorCode() + " " + ex.getMessage());
   }
   if (!ok) {
     FacesContext.getCurrentInstance().addMessage(null, fMsg);
   }
   //        context.addCallbackParam("okUpc", ok);
   return ok;
 }
Пример #4
0
 @Override
 public void validate(FacesContext context, UIComponent component, Object value)
     throws ValidatorException {
   if (value instanceof String) {
     String enteredOgrn = ((String) value).replaceAll("_+$", "");
     Matcher matcher = OGRN_OGRNIP_REGEX.matcher(enteredOgrn);
     if (!matcher.matches()) {
       FacesMessage message = new FacesMessage();
       message.setDetail(ERROR_MESSAGE);
       message.setSummary(ERROR_MESSAGE);
       message.setSeverity(FacesMessage.SEVERITY_ERROR);
       context.addMessage(component.getClientId(), message);
       throw new ValidatorException(message);
     } else {
       boolean correct = true;
       int length;
       BigInteger divisor;
       if (enteredOgrn.length() == OGRN_LENGTH) {
         length = OGRN_LENGTH;
         divisor = OGRN_DIVISOR;
       } else {
         length = OGRNIP_LENGTH;
         divisor = OGRNIP_DIVISOR;
       }
       int last = Character.getNumericValue(enteredOgrn.charAt(length - 1));
       BigInteger ogrn = new BigInteger(enteredOgrn.substring(0, length - 1));
       BigInteger[] divisionResult = ogrn.divideAndRemainder(divisor);
       int remainder = divisionResult[1].intValue();
       if (remainder > REMAINDER_THRESHOLD) {
         remainder = remainder % 10;
       }
       if (remainder != last) {
         correct = false;
       }
       if (!correct) {
         FacesMessage message = new FacesMessage();
         message.setDetail(INCORRECT_BY_CHECK_DIGIT);
         message.setSummary(INCORRECT_BY_CHECK_DIGIT);
         message.setSeverity(FacesMessage.SEVERITY_ERROR);
         context.addMessage(component.getClientId(), message);
         throw new ValidatorException(message);
       }
     }
   } else {
     FacesMessage message = new FacesMessage();
     message.setDetail(ERROR_MESSAGE);
     message.setSummary(ERROR_MESSAGE);
     message.setSeverity(FacesMessage.SEVERITY_ERROR);
     context.addMessage(component.getClientId(), message);
     throw new ValidatorException(message);
   }
 }
  /*
   * (non-Javadoc)
   * @see javax.faces.validator.Validator#validate(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
   */
  @Override
  public void validate(FacesContext facesContext, UIComponent uiComponent, Object value)
      throws ValidatorException {
    UserList userList = (UserList) Component.getInstance("userList");
    String messageDetail = null;
    String messageSummary = null;

    String userName = value.toString();
    if (!isValid(userName)) {
      messageDetail = ResourceBundle.instance().getString("validator.email");
      messageSummary = ResourceBundle.instance().getString("validator.email");
    } else {
      Integer userId = userList.getUserIdForUsername(userName);
      if (userId != null) {
        messageDetail =
            ResourceBundle.instance()
                .getString("org.ideaproject.jsf.validator.USERNAME_TAKEN_detail");
        messageSummary =
            ResourceBundle.instance().getString("org.ideaproject.jsf.validator.USERNAME_TAKEN");
      }
    }

    if (messageDetail != null && messageSummary != null) {
      FacesMessage message = new FacesMessage();
      message.setSeverity(FacesMessage.SEVERITY_ERROR);
      message.setSummary(messageSummary);
      message.setDetail(messageDetail);
      throw new ValidatorException(message);
    }
  }
Пример #6
0
  public void validatePartialCredit(FacesContext context, UIComponent toValidate, Object value) {
    Integer pCredit = null;
    boolean isValid = true;
    if ("0.0".equals(value.toString())) {
      pCredit = 0;
    } else {
      try {
        pCredit = Integer.parseInt(value.toString());
      } catch (NumberFormatException e) {
        isValid = false;
      }
    }

    if (isValid && (pCredit == null || pCredit < 0 || pCredit > 99)) {
      isValid = false;
    }

    if (!isValid) {
      ((UIInput) toValidate).setValid(false);
      FacesMessage message = new FacesMessage();
      message.setSeverity(FacesMessage.SEVERITY_ERROR);
      String summary =
          ContextUtil.getLocalizedString(
              "org.sakaiproject.tool.assessment.bundle.AuthorMessages",
              "partial_credit_limit_summary");
      String detail =
          ContextUtil.getLocalizedString(
              "org.sakaiproject.tool.assessment.bundle.AuthorMessages",
              "partial_credit_limit_detail");
      message.setSummary(summary);
      message.setDetail(detail);
      context.addMessage(toValidate.getClientId(context), message);
    }
  }
Пример #7
0
 private void addMessage(String message, Severity severity, String componentId) {
   FacesMessage msg = new FacesMessage();
   msg.setDetail(message);
   msg.setSeverity(severity);
   UIComponent uic = getComponent(componentId, FacesContext.getCurrentInstance().getViewRoot());
   FacesContext.getCurrentInstance()
       .addMessage(uic.getClientId(FacesContext.getCurrentInstance()), msg);
 }
  public void warningValidator(FacesContext facesContext, UIComponent uiComponent, Object value)
      throws ValidatorException {

    FacesMessage facesMessage = new FacesMessage();
    facesMessage.setSeverity(FacesMessage.SEVERITY_WARN);
    facesMessage.setDetail("This is a warning message.");
    facesContext.addMessage(uiComponent.getClientId(), facesMessage);
  }
Пример #9
0
  public void crearPeriodo() {
    FacesMessage fMsg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Aviso:", "");
    if (this.zona == null || this.zona.getIdZona() == 0) {
      fMsg.setDetail("Seleccione una zona !!");
    } else if (this.grupo == null || this.grupo.getIdGrupo() == 0) {
      fMsg.setDetail("Seleccione un grupo !!");
    } else if (this.periodo.equals("1")) {
      fMsg.setDetail("No se puede crear un período actual, debe ser uno siguiente !!");
    } else if (this.detalles.isEmpty()) {
      try {
        Date fechaInicial = Utilerias.addDays(fechaTope, 1);

        this.dao = new DAOImpuestosDetalle();
        this.detalles =
            this.dao.crearPeriodo(
                this.zona.getIdZona(),
                this.grupo.getIdGrupo(),
                this.periodo,
                new java.sql.Date(fechaInicial.getTime()));
        this.detalle = null;

        fMsg.setSeverity(FacesMessage.SEVERITY_INFO);
        fMsg.setDetail("La operación se realizó con éxito !!");
      } catch (SQLException ex) {
        fMsg.setSeverity(FacesMessage.SEVERITY_ERROR);
        fMsg.setDetail(ex.getErrorCode() + " " + ex.getMessage());
      } catch (NamingException ex) {
        fMsg.setSeverity(FacesMessage.SEVERITY_ERROR);
        fMsg.setDetail(ex.getMessage());
      }
    } else {
      fMsg.setDetail("Ya existe un período siguiente, modifique o elimine y velva a crear !!");
    }
    FacesContext.getCurrentInstance().addMessage(null, fMsg);
  }
Пример #10
0
 public MiniCliente obtenerMiniCliente(int idCliente) {
   boolean ok = false;
   FacesMessage fMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Aviso:", "cargaTiendas");
   MiniCliente mini = null;
   try {
     this.dao = new DAOClientes();
     mini = this.dao.convertirMiniCliente(this.dao.obtenerCliente(idCliente));
     ok = true;
   } catch (SQLException ex) {
     fMsg.setDetail(ex.getErrorCode() + " " + ex.getMessage());
   } catch (NamingException ex) {
     fMsg.setDetail(ex.getMessage());
   }
   if (!ok) {
     FacesContext.getCurrentInstance().addMessage(null, fMsg);
   }
   return mini;
 }
Пример #11
0
 public Upc obtenerUpc(int idProducto) {
   Upc u = null;
   boolean ok = false;
   FacesMessage fMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Aviso:", "obtenerUpc");
   try {
     this.dao = new DAOUpcs();
     u = this.dao.obtenerUpc(idProducto);
     ok = true;
   } catch (NamingException ex) {
     fMsg.setDetail(ex.getMessage());
   } catch (SQLException ex) {
     fMsg.setDetail(ex.getErrorCode() + " " + ex.getMessage());
   }
   if (!ok) {
     FacesContext.getCurrentInstance().addMessage(null, fMsg);
   }
   return u;
 }
Пример #12
0
 public boolean modificar() {
   boolean ok = false;
   FacesMessage fMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Aviso:", "modificar: mbUpc");
   //        RequestContext context = RequestContext.getCurrentInstance();
   try {
     this.dao = new DAOUpcs();
     this.dao.modificar(this.upc);
     ok = true;
   } catch (NamingException ex) {
     fMsg.setDetail(ex.getMessage());
   } catch (SQLException ex) {
     fMsg.setDetail(ex.getErrorCode() + " " + ex.getMessage());
   }
   if (!ok) {
     FacesContext.getCurrentInstance().addMessage(null, fMsg);
   }
   //        context.addCallbackParam("okUpc", ok);
   return ok;
 }
Пример #13
0
 @Override
 public void validate(FacesContext ctx, UIComponent cmpt, Object valor) throws ValidatorException {
   if (!validaCPF(String.valueOf(valor))) {
     FacesMessage message = new FacesMessage();
     message.setDetail("Por favor digite um CPF válido!");
     message.setSummary("Por favor digite um CPF válido!");
     message.setSeverity(FacesMessage.SEVERITY_ERROR);
     throw new ValidatorException(message);
   }
 }
Пример #14
0
 private void cargaMiniClientes() {
   boolean ok = false;
   FacesMessage fMsg =
       new FacesMessage(FacesMessage.SEVERITY_ERROR, "Aviso:", "cargaMiniClientes");
   this.miniClientes = new ArrayList<MiniCliente>();
   try {
     this.dao = new DAOClientes();
     for (TOCliente to : this.dao.obtenerClientes(this.idClienteGpo, this.idFormato)) {
       this.miniClientes.add(this.dao.convertirMiniCliente(to));
     }
     ok = true;
   } catch (SQLException ex) {
     fMsg.setDetail(ex.getErrorCode() + " " + ex.getMessage());
   } catch (NamingException ex) {
     fMsg.setDetail(ex.getMessage());
   }
   if (!ok) {
     FacesContext.getCurrentInstance().addMessage(null, fMsg);
   }
 }
Пример #15
0
  public void eliminarPeriodo() {
    FacesMessage fMsg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Aviso:", "");
    if (this.zona == null || this.zona.getIdZona() == 0) {
      fMsg.setDetail("Seleccione una zona !!");
    } else if (this.grupo == null || this.grupo.getIdGrupo() == 0) {
      fMsg.setDetail("Seleccione un grupo !!");
    } else if (this.periodo.equals("1")) {
      fMsg.setDetail("No se puede eliminar el período actual !!");
    } else {
      try {
        this.dao = new DAOImpuestosDetalle();
        this.dao.eliminarPeriodo(this.zona.getIdZona(), this.grupo.getIdGrupo());
        this.detalles = new ArrayList<ImpuestoDetalle>();
        this.detalle = null;

        fMsg.setSeverity(FacesMessage.SEVERITY_INFO);
        fMsg.setDetail("La operación se realizó con éxito !!");
      } catch (SQLException ex) {
        fMsg.setSeverity(FacesMessage.SEVERITY_ERROR);
        fMsg.setDetail(ex.getErrorCode() + " " + ex.getMessage());
      } catch (NamingException ex) {
        fMsg.setSeverity(FacesMessage.SEVERITY_ERROR);
        fMsg.setDetail(ex.getMessage());
      }
    }
    FacesContext.getCurrentInstance().addMessage(null, fMsg);
  }
Пример #16
0
 public void grabar() {
   FacesMessage fMsg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Aviso:", "");
   if (this.zona == null || this.zona.getIdZona() == 0) {
     fMsg.setDetail("Seleccione una zona !!");
   } else if (this.grupo == null || this.grupo.getIdGrupo() == 0) {
     fMsg.setDetail("Seleccione un grupo !!");
   } else if (this.detalle == null || this.detalle.getImpuesto().getIdImpuesto() == 0) {
     fMsg.setDetail("Seleccione un impuesto de la lista !!");
   } else {
     try {
       this.dao = new DAOImpuestosDetalle();
       this.detalles =
           this.dao.grabar(zona.getIdZona(), grupo.getIdGrupo(), this.detalle, this.periodo);
       fMsg.setSeverity(FacesMessage.SEVERITY_INFO);
       fMsg.setDetail("La operación se realizó con éxito !!");
     } catch (SQLException ex) {
       fMsg.setSeverity(FacesMessage.SEVERITY_ERROR);
       fMsg.setDetail(ex.getErrorCode() + " " + ex.getMessage());
     } catch (NamingException ex) {
       fMsg.setSeverity(FacesMessage.SEVERITY_ERROR);
       fMsg.setDetail(ex.getMessage());
     }
   }
   FacesContext.getCurrentInstance().addMessage(null, fMsg);
 }
Пример #17
0
  public void validate(FacesContext _context, UIComponent _toValidate, Object _value)
      throws ValidatorException {

    UIComponent component = _toValidate.findComponent("equal1");
    String valeur = (String) component.getAttributes().get("value");

    if (!_value.equals(valeur) || valeur.equals("") || _value.equals("")) {
      FacesMessage message = new FacesMessage();
      message.setSeverity(FacesMessage.SEVERITY_ERROR);
      message.setDetail("Les deux champs ne sont pas identiques");
      throw new ValidatorException(message);
    }
  }
Пример #18
0
  @Override
  public void validate(FacesContext context, UIComponent component, Object value)
      throws ValidatorException {

    String pesel = (String) value;

    if (pesel.length() != 4) {
      FacesMessage message = new FacesMessage();
      message.setDetail("PIN musi składać się z 4 cyfr");
      message.setSummary("PIN musi składać się z 4 cyfr");
      message.setSeverity(FacesMessage.SEVERITY_ERROR);
      throw new ValidatorException(message);
    }
  }
Пример #19
0
  public void handleReorder(DashboardReorderEvent event) {
    FacesMessage message = new FacesMessage();
    message.setSeverity(FacesMessage.SEVERITY_INFO);
    message.setSummary("Reordered: " + event.getWidgetId());
    message.setDetail(
        "Item index: "
            + event.getItemIndex()
            + ", Column index: "
            + event.getColumnIndex()
            + ", Sender index: "
            + event.getSenderColumnIndex());

    addMessage(message);
  }
Пример #20
0
 public void cargaListaUpcs() {
   boolean ok = false;
   RequestContext context = RequestContext.getCurrentInstance();
   FacesMessage fMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Aviso:", "cargaListaUpcs");
   this.listaUpcs = new ArrayList<SelectItem>();
   Upc u0 = this.nuevoLista(this.upc.getIdProducto());
   this.listaUpcs.add(new SelectItem(u0, u0.toString()));
   try {
     this.dao = new DAOUpcs();
     for (Upc u : this.dao.obtenerUpcs(this.upc.getIdProducto())) {
       this.listaUpcs.add(new SelectItem(u, u.toString()));
     }
     ok = true;
   } catch (NamingException ex) {
     fMsg.setDetail(ex.getMessage());
   } catch (SQLException ex) {
     fMsg.setDetail(ex.getErrorCode() + " " + ex.getMessage());
   }
   if (!ok) {
     FacesContext.getCurrentInstance().addMessage(null, fMsg);
   }
   context.addCallbackParam("okUpc", ok);
 }
Пример #21
0
  /* (non-Javadoc)
   * @see javax.faces.validator.Validator#validate(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
   */
  @Override
  public void validate(FacesContext arg0, UIComponent arg1, Object value)
      throws ValidatorException {
    if (value != null) {

      if (!getUserService().isUsernameAvailable((String) value)
          || !getUserService().isEmailAvailable((String) value)) {
        FacesMessage message = new FacesMessage();
        message.setDetail(value + " is not available. Choose another name.");
        message.setSummary("Not available");
        message.setSeverity(FacesMessage.SEVERITY_WARN);
        throw new ValidatorException(message);
      }
    }
  }
 @Override
 public void validate(FacesContext context, UIComponent component, Object value)
     throws ValidatorException {
   if (value == null
       || "".equals(value.toString().trim())
       || (!value.toString().trim().equals(Constants.PLACE_ACCOUNT_TYPE)
           && !value.toString().trim().equals(Constants.USER_ACCOUNT_TYPE))) {
     FacesMessage facesMessage = new FacesMessage();
     String message = (String) component.getAttributes().get("message");
     facesMessage.setDetail(message);
     facesMessage.setSummary(message);
     facesMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
     throw new ValidatorException(facesMessage);
   }
 }
 private static void replaceIdWithLabel(
     String clientId, FacesMessage message, FacesContext facesContext) {
   UIComponent label = findLabelFor(facesContext.getViewRoot(), clientId);
   if (label != null) {
     int idx = clientId.lastIndexOf(':');
     if (idx >= 0) {
       clientId = clientId.substring(idx + 1);
     }
     log.debug("Replacing ID with Label for: " + clientId);
     String text = (String) label.getAttributes().get("value");
     String detail = message.getDetail();
     String summary = message.getSummary();
     message.setSummary(summary.replaceAll(clientId, text));
     message.setDetail(detail.replaceAll(clientId, text));
   } else {
     log.debug("Unabled to find a label for ID: " + clientId);
   }
 }
  // Переопределяем метод для валидации поля
  @Override
  public void validate(FacesContext fc, UIComponent uic, Object o) throws ValidatorException {
    String email = (String) o;
    if (email != "") {
      try {
        InternetAddress emailAddr = new InternetAddress(email);
        emailAddr.validate();
      } catch (AddressException ex) {
        FacesContext context = FacesContext.getCurrentInstance();
        ResourceBundle bundle = context.getApplication().getResourceBundle(context, "msgs");
        String msgStr = bundle.getString("validatorEmailErrorFormat");

        FacesMessage message = new FacesMessage();
        message.setDetail(msgStr);
        message.setSummary(msgStr);
        message.setSeverity(FacesMessage.SEVERITY_ERROR);
        throw new ValidatorException(message);
      }
    }
  }
Пример #25
0
  public void validate(FacesContext context, UIComponent component, Object pvalue)
      throws ValidatorException {
    String value = (String) pvalue;

    String num = "^[0-9]*";
    String ex = "(|-|,|/)?[0-9]*$";

    Pattern mask = Pattern.compile(num + ex);

    Matcher matcher = mask.matcher(value);

    if (!matcher.find()) {
      FacesMessage message = new FacesMessage();
      message.setSummary(
          ECPubFun.getDisplayString(Constants.BUNDLE_PROGRAM, "Valitator_PhoneInvalid", null));
      message.setDetail(
          ECPubFun.getDisplayString(Constants.BUNDLE_PROGRAM, "Valitator_PhoneInvalid", null));
      message.setSeverity(FacesMessage.SEVERITY_ERROR);
      throw new ValidatorException(message);
    }
  }
  /**
   * This method is action listener for select privileges drop down
   *
   * @param valueChangeEvent - object of ValueChangeEvent
   */
  public void selectPrivilegesListener(ValueChangeEvent valueChangeEvent) {
    try {
      String newValue = String.valueOf(valueChangeEvent.getNewValue());
      if (categoryIdList.contains(newValue) && newValue != CAPMETRIC_LIST_DROPDOWN_SELECT) {
        RichSelectOneChoice privilegeSelectOneChoice =
            (RichSelectOneChoice) findComponentInRoot(DEL_PRIV_UICOMP);
        FacesMessage message = new FacesMessage();
        message.setDetail(getValue("#{CommonResourceText['CATEGORY_NOT_CHOOSEN']}"));
        message.setSeverity(FacesMessage.SEVERITY_ERROR);

        // Reset resource area to default value
        FacesContext.getCurrentInstance()
            .addMessage(
                privilegeSelectOneChoice.getClientId(FacesContext.getCurrentInstance()), message);
        privilegeSelectOneChoice.setValue(0);
        privilegeSelectOneChoice.setValid(false);
        AdfFacesContext.getCurrentInstance().addPartialTarget(privilegeSelectOneChoice);
      }
      OPPE_LOG.debug("METRICS.VALUE_CHANE_EVENT_DEBUG");
    } catch (Exception exception) {
      OPPE_LOG.error("DATABASE_RETRIEVE_ERROR", exception);
      showGenericError();
    }
  }
Пример #27
0
  public void validate(FacesContext context, UIComponent component, Object value)
      throws ValidatorException {
    ModelValidator modelValidator = new ModelValidator();
    modelValidator.validate(context, component, value);

    UIInput accountNumberField =
        (UIInput) context.getViewRoot().findComponent("#{rich:clientId('amountWithoutTax')}");
    System.out.println(
        "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa"
            + accountNumberField);

    BigDecimal amountWithoutTax = (BigDecimal) component.getAttributes().get(amountWithoutTaxID);
    BigDecimal amount2 = (BigDecimal) value;
    ChargeTemplate chargeTemplate =
        (ChargeTemplate) component.getAttributes().get(chargeTemplateID);
    if (!validateOneShotChargeInstanceAmount(chargeTemplate, amountWithoutTax, amount2)) {
      FacesMessage facesMessage = new FacesMessage();
      String message = SeamResourceBundle.getBundle().getString("commons.checkAmountHTandTTC");
      facesMessage.setDetail(message);
      facesMessage.setSummary(message);
      facesMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
      // throw new ValidatorException(facesMessage);
    }
  }
Пример #28
0
 public void setDetail(String arg0) {
   message.setDetail(arg0);
 }
Пример #29
0
 public String changePassword() {
   if (getUserAuth().getOldPassword() == null || getUserAuth().getOldPassword().trim().isEmpty()) {
     FacesMessage message = new FacesMessage();
     message.setDetail("La password corrente e' vuota!");
     message.setSeverity(FacesMessage.SEVERITY_ERROR);
     message.setSummary("Errore password corrente");
     FacesContext.getCurrentInstance().addMessage("pwd:opwd", message);
     return null;
   }
   String oldPassword = PasswordUtils.createPassword(getUserAuth().getOldPassword());
   if (!oldPassword.equals(getUserAuth().getPassword())) {
     FacesMessage message = new FacesMessage();
     message.setDetail("La password corrente non e' corretta!");
     message.setSeverity(FacesMessage.SEVERITY_ERROR);
     message.setSummary("Errore password corrente");
     FacesContext.getCurrentInstance().addMessage("pwd:opwd", message);
     return null;
   }
   if (getUserAuth().getNewPassword() == null || getUserAuth().getNewPassword().length() == 0) {
     FacesMessage message = new FacesMessage();
     message.setDetail("La nuova password non e' stata inserita in entrambi i campi di testo!");
     message.setSeverity(FacesMessage.SEVERITY_ERROR);
     message.setSummary("Errore nuova password");
     FacesContext.getCurrentInstance().addMessage("pwd:npwd", message);
     return null;
   }
   if (getUserAuth().getConfirmPassword() == null
       || getUserAuth().getConfirmPassword().length() == 0) {
     FacesMessage message = new FacesMessage();
     message.setDetail("La nuova password non e' stata inserita in entrambi i campi di testo!");
     message.setSeverity(FacesMessage.SEVERITY_ERROR);
     message.setSummary("Errore nuova password");
     FacesContext.getCurrentInstance().addMessage("pwd:cpwd", message);
     return null;
   }
   if (!userAuth.getNewPassword().equals(userAuth.getConfirmPassword())) {
     FacesMessage message = new FacesMessage();
     message.setDetail(
         "Sono stati inseriti valori diversi nei due campi di testo relativi alla nuova password!");
     message.setSeverity(FacesMessage.SEVERITY_ERROR);
     message.setSummary("Errore nuova password");
     FacesContext.getCurrentInstance().addMessage("pwd:cpwd", message);
     return null;
   }
   String newPassword = PasswordUtils.createPassword(getUserAuth().getNewPassword());
   getUserAuth().setPassword(newPassword);
   userRepository.update(getUserAuth());
   logOperationsController.save(
       OperazioniLog.MODIFY,
       JSFUtils.getUserName(),
       "cambio pwd utente: " + this.userAuth.getUsername());
   ExternalContext extCtx = FacesContext.getCurrentInstance().getExternalContext();
   try {
     extCtx.redirect(extCtx.encodeActionURL(LOGOUT));
   } catch (Exception e) {
     FacesMessage message = new FacesMessage("Errore generico, riprovare piu' tardi!");
     message.setSeverity(FacesMessage.SEVERITY_ERROR);
     message.setSummary("Errore generico");
     FacesContext.getCurrentInstance().addMessage("pwd:cpwd", message);
     return null;
   }
   return null;
 }