Esempio n. 1
0
 @NotSaved
 public ActionOutcome save() {
   currentPlayer.setName(username);
   currentPlayer.setPassword(password);
   if (phoneOrEmail != null) {
     String phone = parsePhone(phoneOrEmail);
     if (phone != null) {
       currentPlayer.setPhone(phone);
     } else {
       currentPlayer.setEmail(parseEmail(phoneOrEmail));
     }
   }
   currentPlayer.setSaved(true);
   playerEventSrc.fire(cem.save(currentPlayer, false));
   return ActionOutcome.success;
 }
Esempio n. 2
0
 public void validateUsername(FacesContext ctx, UIComponent toValidate, Object value) {
   if (!currentPlayer.getName().equals(value)) {
     String username = value.toString();
     try {
       new MessageFormat(Bundles.Common.message("reg.newbie.login")).parse(username);
       ((UIInput) toValidate).setValid(false);
       ctx.addMessage(
           toValidate.getClientId(ctx),
           Bundles.Common.message(FacesMessage.SEVERITY_ERROR, "error.username.reserved"));
     } catch (ParseException e) {
       if (cem.findByAttribute(Player_.name, username) != null) {
         ((UIInput) toValidate).setValid(false);
         ctx.addMessage(
             toValidate.getClientId(ctx),
             Bundles.Common.message(FacesMessage.SEVERITY_ERROR, "error.username.occupied"));
       }
     }
   }
 }