public void testTorrent(AjaxBehaviorEvent event) { // TODO Это точно такая же часть как и в testMessage FacesContext context = FacesContext.getCurrentInstance(); UIComponent component = UIComponent.getCurrentComponent(context); String url = (String) ((UIInput) component.findComponent("filmLinkRutracker")).getValue(); WebBrowser webBrowser = new WebBrowser(LogEnum.WEB.getLog()); // String regexp = (String) ((UIInput) component.findComponent("filmRegexpSerialNumber")).getValue(); FacesMessage message = new FacesMessage(); try { webBrowser.goToUrl(url); filmEdit.setTitle(webBrowser.getTitle()); TorrentFile torrent = webBrowser.downloadTorrentFile(webBrowser.getTorrentUrl()); ByteArrayInputStream bais = new ByteArrayInputStream(torrent.getContent()); TorrentInfo info = new TorrentInfo(new BufferedInputStream(bais)); StringBuilder builder = new StringBuilder(); for (String fileName : info.getInfo()) { builder .append(fileName) .append(" № серии: \"") .append(MessageUtils.parseEpisode(fileName, regexp)) .append("\" "); } message.setSummary(builder.toString()); message.setSeverity(FacesMessage.SEVERITY_INFO); } catch (CoreException e) { message.setSeverity(FacesMessage.SEVERITY_ERROR); message.setSummary(e.getMessage()); } context.addMessage("otherMessageHidden", message); context.renderResponse(); }
public void adcionarItemTratamento() { ItemTratamento atualItem = null; boolean tem = false; for (ItemTratamento itemTratamento1 : this.tratamento.getItensTratamentos()) { if (itemTratamento1.getItemEstoque().equals(this.itemEstoqueSelecionado)) { atualItem = itemTratamento1; tem = true; } } if (tem) { Long novaQuant = atualItem.getQuantidade_consumida() + this.itemTratamento.getQuantidade_consumida(); if (this.itemTratamento.getQuantidade_consumida() <= this.itemEstoqueSelecionado.getQuantidade_estoque()) { this.itemEstoqueSelecionado.setQuantidade_estoque( this.itemEstoqueSelecionado.getQuantidade_estoque() - this.itemTratamento.getQuantidade_consumida()); this.daoGenerico.atualizar(itemEstoqueSelecionado); atualItem.setQuantidade_consumida(novaQuant); this.itemTratamento = new ItemTratamento(); } else { FacesMessage message = new FacesMessage(); String msg = "QUANTIDADE NÃO PERMITIDA!"; message.setSeverity(FacesMessage.SEVERITY_ERROR); message.setSummary(msg); FacesContext.getCurrentInstance().addMessage(null, message); this.itemTratamento.setQuantidade_consumida(null); } } else { if (this.itemTratamento.getQuantidade_consumida() <= this.itemEstoqueSelecionado.getQuantidade_estoque()) { this.itemEstoqueSelecionado.setQuantidade_estoque( this.itemEstoqueSelecionado.getQuantidade_estoque() - this.itemTratamento.getQuantidade_consumida()); this.daoGenerico.atualizar(itemEstoqueSelecionado); List<ItemTratamento> itemTratamentos = this.tratamento.getItensTratamentos(); this.itemTratamento.setItemEstoque(itemEstoqueSelecionado); itemTratamentos.add(itemTratamento); this.tratamento.setItensTratamentos(itemTratamentos); this.itemTratamento = new ItemTratamento(); } else { FacesMessage message = new FacesMessage(); String msg = "QUANTIDADE NÃO PERMITIDA!"; message.setSeverity(FacesMessage.SEVERITY_ERROR); message.setSummary(msg); FacesContext.getCurrentInstance().addMessage(null, message); this.itemTratamento.setQuantidade_consumida(null); } } }
@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); } }
public void salvarTratamento() { FacesMessage message = new FacesMessage(); String msg = "TRATAMENTO CADASTRADO COM SUCESSO!"; message.setSeverity(FacesMessage.SEVERITY_INFO); if (this.tratamento.getId() != null) { if (this.pacienteSelecionado != null) { this.carregarDentista(); this.tratamento.setPaciente(pacienteSelecionado); this.tratamento.setDentista(dentista); if (!this.tratamento.getServicosPrestados().isEmpty()) { double total = 0; for (ServicoPrestado servicoPrestado : this.tratamento.getServicosPrestados()) { total = total + servicoPrestado.getValor().doubleValue(); } this.tratamento.getPagamento().setValorTotal(new BigDecimal(total)); } Tratamento t = this.daoGenerico.atualizar(this.tratamento); this.tratamento = new Tratamento(); this.pacienteSelecionado = null; this.tratamentoTodos = this.daoGenerico.tratamentoPorDentista(this.dentista); if (t == null) { msg = "ERRO AO CADASTRAR TRATAMENTO!"; message.setSeverity(FacesMessage.SEVERITY_ERROR); } } else { msg = "TRATAMENTO CADASTRADO COM SUCESSO!"; message.setSeverity(FacesMessage.SEVERITY_ERROR); } } else { if (this.pacienteSelecionado != null) { this.carregarDentista(); this.tratamento.setPaciente(pacienteSelecionado); this.tratamento.setStatus("ANDAMENTO"); this.tratamento.getPagamento().setStatusPagamento("ABERTO"); this.tratamento.setDentista(dentista); if (!this.tratamento.getServicosPrestados().isEmpty()) { double total = 0; for (ServicoPrestado servicoPrestado : this.tratamento.getServicosPrestados()) { total = total + servicoPrestado.getValor().doubleValue(); } this.tratamento.getPagamento().setValorTotal(new BigDecimal(total)); } boolean certo = this.daoGenerico.salvar(this.tratamento); this.tratamento = new Tratamento(); this.pacienteSelecionado = null; this.tratamentoTodos = this.daoGenerico.tratamentoPorDentista(this.dentista); if (!certo) { msg = "ERRO AO CADASTRAR TRATAMENTO!"; message.setSeverity(FacesMessage.SEVERITY_ERROR); } } else { msg = "TRATAMENTO CADASTRADO COM SUCESSO!"; message.setSeverity(FacesMessage.SEVERITY_ERROR); } } message.setSummary(msg); FacesContext.getCurrentInstance().addMessage(null, 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); } }
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); } }
@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); } }
@Override public void validate(FacesContext fc, UIComponent uic, Object o) throws ValidatorException { if (!validaCNPJ(String.valueOf(o))) { FacesMessage message = new FacesMessage(); message.setSeverity(FacesMessage.SEVERITY_ERROR); message.setSummary("CNPJ inválido!"); throw new ValidatorException(message); } }
public void validateGroupRegexp(FacesContext context, UIComponent component, Object value) { String strValue = (String) value; try { if (!StringUtils.isEmpty(strValue)) Pattern.compile(strValue); } catch (PatternSyntaxException e) { FacesMessage error = new FacesMessage(); error.setSeverity(FacesMessage.SEVERITY_ERROR); error.setSummary("Не валидное regexp выражение"); throw new ValidatorException(error); } }
public void validateGroupMessage(FacesContext context, UIComponent component, Object value) { String strValue = (String) value; if (StringUtils.isEmpty(strValue)) { UIComponent ui = component.findComponent("groupEmailRegexp"); UIInput input = (UIInput) ui; if (!StringUtils.isEmpty((String) input.getValue())) { FacesMessage error = new FacesMessage(); error.setSeverity(FacesMessage.SEVERITY_ERROR); error.setSummary("Поле обязательно для заполнения"); throw new ValidatorException(error); } } }
@Override public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { // TODO Auto-generated method stub String enteredEmail = (String) value; boolean emailused = getCusto().Checkloginused(enteredEmail); if (emailused) { FacesMessage message = new FacesMessage(); message.setSummary("login already used"); throw new ValidatorException(message); } }
public void gerarOrcamento() { FacesMessage message = new FacesMessage(); String msg = "ORÇAMENTO EMITIDO COM SUCESSO!"; message.setSeverity(FacesMessage.SEVERITY_INFO); if (pacienteSelecionado == null) { msg = "SELECIONE UM PACIENTE!"; message.setSeverity(FacesMessage.SEVERITY_INFO); } else if (this.tratamento.getServicosPrestados() == null || this.tratamento.getServicosPrestados().isEmpty()) { msg = "SELECIONE OS SERVIÇOS À REALIZAR!"; message.setSeverity(FacesMessage.SEVERITY_INFO); } else { this.carregarClinica(); Double total = new Double(0); for (ServicoPrestado servicoPrestado : this.tratamento.getServicosPrestados()) { total = total + servicoPrestado.getValor().doubleValue(); } HashMap<String, Object> parameterMap = new HashMap<String, Object>(); String nomepaciente = this.pacienteSelecionado.getNome() + " " + this.pacienteSelecionado.getSobrenome(); String enderecoClinica = this.clinica.getEndereco().getLogradouro() + ", " + this.clinica.getEndereco().getNumero() + " - " + this.clinica.getEndereco().getBairro() + ", " + this.clinica.getEndereco().getCidade() + "-" + this.clinica.getEndereco().getUf(); String logo = FacesContext.getCurrentInstance() .getExternalContext() .getRealPath("/resources/clinica/" + this.clinica.getLogo()); parameterMap.put("NOME_PACIENTE", nomepaciente); parameterMap.put("CLINICA_LOGO", logo); parameterMap.put("CLINICA_ENDERECO", enderecoClinica); parameterMap.put("CLINICA_EMAIL", this.clinica.getContato().getEmail()); parameterMap.put("CLINICA_TELEFONE", this.clinica.getContato().getTelefone()); parameterMap.put("CLINICA_CELULAR", this.clinica.getContato().getCelular()); parameterMap.put("TOTAL", total); String relatorio = "orcamento.jasper"; RelatorioUtil.gerarRelatorio(relatorio, parameterMap, this.tratamento.getServicosPrestados()); } message.setSummary(msg); FacesContext.getCurrentInstance().addMessage(null, message); }
@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); } }
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); }
public void testMessage(AjaxBehaviorEvent event) { FacesContext context = FacesContext.getCurrentInstance(); UIComponent component = UIComponent.getCurrentComponent(context); String url = (String) ((UIInput) component.findComponent("filmLinkRutracker")).getValue(); WebBrowser webBrowser = new WebBrowser(LogEnum.WEB.getLog()); FacesMessage message = new FacesMessage(); try { webBrowser.goToUrl(url); String title = webBrowser.getTitle(); filmEdit.setTitle(title); String regexp = (String) ((UIInput) component.findComponent("filmMailRegexp")).getValue(); String mailMessage = (String) ((UIInput) component.findComponent("filmMailMessage")).getValue(); message.setSummary(MessageUtils.createMessage(title, regexp, mailMessage)); message.setSeverity(FacesMessage.SEVERITY_INFO); } catch (CoreException e) { message.setSeverity(FacesMessage.SEVERITY_ERROR); message.setSummary(e.getMessage()); } context.addMessage("otherMessageHidden", message); context.renderResponse(); }
@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); } }
/* (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); } } }
public void quitarPagamento() { FacesMessage message = new FacesMessage(); String msg = "PAGAMENTO QUITADO COM SUCESSO!"; message.setSeverity(FacesMessage.SEVERITY_INFO); this.tratamentoSelecionado.getPagamento().setStatusPagamento("QUITADO"); Tratamento t = this.daoGenerico.atualizar(this.tratamentoSelecionado); if (t == null) { msg = "ERRO AO QUITAR PAGAMENTO!"; message.setSeverity(FacesMessage.SEVERITY_ERROR); } message.setSummary(msg); FacesContext.getCurrentInstance().addMessage(null, message); }
public void finalizarTratamento() { FacesMessage message = new FacesMessage(); String msg = "TRATAMENTO FINALIZADO COM SUCESSO!"; message.setSeverity(FacesMessage.SEVERITY_INFO); this.tratamentoSelecionado.setStatus("FINALIZADO"); Tratamento t = this.daoGenerico.atualizar(this.tratamentoSelecionado); if (t == null) { msg = "ERRO AO FINALIZAR TRATAMENTO!"; message.setSeverity(FacesMessage.SEVERITY_ERROR); } message.setSummary(msg); FacesContext.getCurrentInstance().addMessage(null, message); }
private void printMessagesAssociatedWithComponents(FacesContext context) { final Iterator<String> clientsWithMessages = context.getClientIdsWithMessages(); while (clientsWithMessages.hasNext()) { String clientId = clientsWithMessages.next(); final Iterator<FacesMessage> messages = context.getMessages(clientId); while (messages.hasNext()) { final FacesMessage facesMessage = messages.next(); logMessage(clientId, facesMessage); facesMessage.setSummary( facesMessage.getSummary() + " -- tagged by " + this.getClass().getSimpleName()); } } }
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); } } }
public void excluirTratamento() { if (this.tratamentoSelecionado != null) { String msg = "TRATAMENTO REMOVIDO COM SUCESSO!"; FacesMessage message = new FacesMessage(msg); message.setSeverity(FacesMessage.SEVERITY_INFO); boolean certo = true; if (!this.tratamentoSelecionado.getItensTratamentos().isEmpty()) { for (ItemTratamento itemTratamento1 : this.tratamentoSelecionado.getItensTratamentos()) { certo = this.daoGenerico.remover(itemTratamento1); if (!certo) { break; } } } if (!this.tratamentoSelecionado.getServicosPrestados().isEmpty()) { for (ServicoPrestado servicoPrestado : this.tratamentoSelecionado.getServicosPrestados()) { certo = this.daoGenerico.remover(servicoPrestado); if (!certo) { break; } } } if (certo) { certo = this.daoGenerico.remover(this.tratamentoSelecionado); } if (!certo) { msg = "ERRO AO REMOVER TRATAMENTO!"; message.setSummary(msg); message.setSeverity(FacesMessage.SEVERITY_ERROR); } else { this.tratamentoTodos = this.daoGenerico.listarTodos(Tratamento.class); } FacesContext.getCurrentInstance().addMessage(null, message); } }
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); } }
public void saveFilm(AjaxBehaviorEvent event) { WebBrowser webBrowser = new WebBrowser(LogEnum.WEB.getLog()); try { webBrowser.goToUrl(filmEdit.getLinkRutracker()); filmEdit.setTitle(webBrowser.getTitle()); } catch (CoreException e) { // TODO Избавится от такого большого исключения сделать один статический метод FacesMessage error = new FacesMessage(); error.setSeverity(FacesMessage.SEVERITY_ERROR); error.setSummary(e.getMessage()); throw new ValidatorException(error); } if (filmEdit.getType() != TypeDistributionEnum.SERIALS.getType()) { filmEdit.setRegexpSerialNumber(null); filmEdit.setSeasonNumber(null); } DaoFactory.getInstance().getDistributionDao().addDistribution(filmEdit); if (filmList.size() > 0) filmList.add(0, filmEdit); filmList.add(filmEdit); }
public String updateTask() { try { // fetch task and update before sending to database Task t = taskEJB.getTask(taskBean.getTaskId()); t.setAssignedTo(accountEJB.getUser(taskBean.getAssignedUser())); t.setOwner(accountEJB.getUser(taskBean.getOwner())); t.setCompleted(taskBean.isCompleted()); t.setDueDate(taskBean.getDueDate()); t.setNote(taskBean.getNote()); t.setTitle(taskBean.getTitle()); t.setPriority(taskBean.getPriority()); taskEJB.update(t); FacesMessage message = new FacesMessage(); message.setSummary("Task is updated"); message.setSeverity(FacesMessage.SEVERITY_INFO); FacesContext ctxt = FacesContext.getCurrentInstance(); ctxt.addMessage(null, message); } catch (Exception ex) { Logger.getLogger(TaskController.class.getSimpleName()).log(Level.SEVERE, ex.getMessage()); } return "tasks"; }
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); } }
public void setSummary(String arg0) { message.setSummary(arg0); }
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; }