예제 #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);
 }
예제 #2
0
 /** Returns the form errors serialized as Json using the given Lang. */
 public com.fasterxml.jackson.databind.JsonNode errorsAsJson(play.i18n.Lang lang) {
   Map<String, List<String>> allMessages = new HashMap<>();
   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) {
         if (messagesApi != null && lang != null) {
           messages.add(
               messagesApi.get(
                   lang, error.messages(), translateMsgArg(error.arguments(), messagesApi, lang)));
         } else {
           messages.add(error.message());
         }
       }
       allMessages.put(key, messages);
     }
   }
   return play.libs.Json.toJson(allMessages);
 }