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 c34ab11ff..ab8af5aa3 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,7 +140,6 @@ 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 a3f935b21..364097114 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 @@ -22,7 +22,10 @@ import java.util.List; import java.util.Map; +import javax.annotation.PostConstruct; import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.servlet.http.HttpServletRequest; import org.slf4j.Logger; @@ -49,6 +52,29 @@ public class Messages { private Map> messages = new HashMap<>(); private boolean unhandledErrors = false; + private final HttpServletRequest request; + + /** + * @deprecated CDI eyes only + */ + protected Messages() { + this(null); + } + + @Inject + public Messages(HttpServletRequest request) { + this.request = request; + } + + /** + * Put this instance into request attributes to allow this instance survive between requests using flash + * scope. + */ + @PostConstruct + public void init() { + request.setAttribute(ATTRIBUTE_KEY, this); + } + public Messages add(Message message) { get(message.getSeverity()).add(message); if(Severity.ERROR.equals(message.getSeverity())) {