Ejemplo n.º 1
0
 /** Returns the form errors serialized as Json using the given Lang. */
 public org.codehaus.jackson.JsonNode errorsAsJson(play.i18n.Lang lang) {
   Map<String, List<String>> allMessages = new HashMap<String, List<String>>();
   for (String key : errors.keySet()) {
     List<ValidationError> errs = errors.get(key);
     if (errs != null && !errs.isEmpty()) {
       List<String> messages = new ArrayList<String>();
       for (ValidationError error : errs) {
         messages.add(play.i18n.Messages.get(lang, error.message(), error.arguments()));
       }
       allMessages.put(key, messages);
     }
   }
   return play.libs.Json.toJson(allMessages);
 }
Ejemplo n.º 2
0
 /**
  * Adds an error to this form.
  *
  * @param error the <code>ValidationError</code> to add.
  */
 public void reject(ValidationError error) {
   if (!errors.containsKey(error.key())) {
     errors.put(error.key(), new ArrayList<ValidationError>());
   }
   errors.get(error.key()).add(error);
 }