public void validateAccounts() { boolean valid = true; // The account to merge in has been authenticated if (obsoleteAccount != null) { if (obsoleteAccount.getId() == null) { facesMessages.addGlobal(SEVERITY_ERROR, "Could not find an account for that user."); valid = false; } else if (authenticatedAccount.getId().equals(obsoleteAccount.getId())) { facesMessages.addGlobal(SEVERITY_ERROR, "You are attempting to merge the same account."); valid = false; } } this.accountsValid = valid; }
public void validateHumanField() { if (humanField != null && humanField.length() > 0) { valid = false; facesMessages.addGlobal( SEVERITY_ERROR, "You have filled a field that was not meant for humans."); humanField = null; } }
@Transactional public void deleteTransMemory(String transMemorySlug) { try { translationMemoryResource.deleteTranslationMemory(transMemorySlug); transMemoryList = null; // Force refresh next time list is requested } catch (EntityMissingException e) { facesMessages.addFromResourceBundle(SEVERITY_ERROR, "jsf.transmemory.TransMemoryNotFound"); } }
public void validateUsername(String username) { try { entityManager .createQuery("from HAccount a where a.username = :username") .setParameter("username", username) .getSingleResult(); valid = false; facesMessages.addToControl("username", "This username is not available"); } catch (NoResultException e) { // pass } }
protected final <T extends Throwable> void handle( ExceptionEvent<T> event, LogLevel logLevel, String redirectUrl, FacesMessage.Severity severity, String messageKey, Object... messageArgs) { logException(logLevel, event.getException()); if (ContextUtils.isContextActive(WindowScoped.class)) { messages.clear(); messages.addFromResourceBundle(severity, messageKey, messageArgs); urlUtil.redirectTo(redirectUrl); // TODO urlUtil.forwardTo(redirectPath); // required - "stops" the JSF lifecycle FacesContext.getCurrentInstance().responseComplete(); } // no other ExceptionHandler should handle this exception... event.handled(); }
@End public String register() { valid = true; validateUsername(getUsername()); validateHumanField(); if (!isValid()) { return null; } final String user = getUsername(); final String pass = getPassword(); final String email = getEmail(); String key = registerServiceImpl.register(user, pass, getPerson().getName(), email); log.info("get register key:" + key); String message = emailServiceImpl.sendActivationEmail(user, email, key); facesMessages.addGlobal(message); return "/home.xhtml"; }
public void mergeAccounts() { registerServiceImpl.mergeAccounts(authenticatedAccount, obsoleteAccount); obsoleteAccount = null; // reset the obsolete account facesMessages.addGlobal("Your accounts have been merged."); }
@Override public void onComplete() { jsfMessages.addGlobal( FacesMessage.SEVERITY_INFO, msgs.format("jsf.iteration.CopyTrans.Completed", getProjectSlug(), getVersionSlug())); }