From 780bb917889bf88d8cef6e1bbb90be6f27d4f1a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Garcia?= Date: Tue, 16 Sep 2014 02:22:51 -0300 Subject: [PATCH] Adding Messages as request attribute to enforce flash scope when redirect --- .../br/com/caelum/vraptor/validator/DefaultValidator.java | 1 + .../main/java/br/com/caelum/vraptor/validator/Messages.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/vraptor-core/src/main/java/br/com/caelum/vraptor/validator/DefaultValidator.java b/vraptor-core/src/main/java/br/com/caelum/vraptor/validator/DefaultValidator.java index ab8af5aa3..c34ab11ff 100644 --- a/vraptor-core/src/main/java/br/com/caelum/vraptor/validator/DefaultValidator.java +++ b/vraptor-core/src/main/java/br/com/caelum/vraptor/validator/DefaultValidator.java @@ -140,6 +140,7 @@ public T onErrorUse(Class view) { } result.include("errors", getErrors()); + result.include(Messages.ATTRIBUTE_KEY, messages); outjector.outjectRequestMap(); logger.debug("there are errors on result: {}", getErrors()); diff --git a/vraptor-core/src/main/java/br/com/caelum/vraptor/validator/Messages.java b/vraptor-core/src/main/java/br/com/caelum/vraptor/validator/Messages.java index 6172a96b3..a3f935b21 100644 --- a/vraptor-core/src/main/java/br/com/caelum/vraptor/validator/Messages.java +++ b/vraptor-core/src/main/java/br/com/caelum/vraptor/validator/Messages.java @@ -23,7 +23,6 @@ import java.util.Map; import javax.enterprise.context.RequestScoped; -import javax.inject.Named; import org.slf4j.Logger; @@ -40,10 +39,11 @@ * @since 4.1 * @author Otávio S Garcia */ -@Named("vmessages") @RequestScoped public class Messages { + public static final String ATTRIBUTE_KEY = "vmessages"; + private final static Logger log = getLogger(Messages.class); private Map> messages = new HashMap<>();