From 00ff018b392c7fb52412363f4180273afed1949b Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 25 Aug 2011 08:11:17 +0000 Subject: [PATCH] SPR-6464 Uncommitted file from the last commit. --- .../method/support/ModelAndViewContainer.java | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/org.springframework.web/src/main/java/org/springframework/web/method/support/ModelAndViewContainer.java b/org.springframework.web/src/main/java/org/springframework/web/method/support/ModelAndViewContainer.java index c1ce67059e..a3a3cefa8d 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/method/support/ModelAndViewContainer.java +++ b/org.springframework.web/src/main/java/org/springframework/web/method/support/ModelAndViewContainer.java @@ -40,7 +40,7 @@ public class ModelAndViewContainer { private ModelMap redirectModel; - private boolean useRedirectModel = false; + private boolean redirectModelEnabled; /** * Create a new instance. @@ -108,35 +108,32 @@ public class ModelAndViewContainer { } /** - * Return the internal model currently in use. Normally this is the - * implicit model created in the constructor of this class. - * However, when a redirect model is provided via {@link #setRedirectModel} - * and then enabled for use via {@link #useRedirectModel()}, this method - * returns the redirect model instead. - * - * @return the internal model currently in use, never {@code null}. + * Return the model to use, never {@code null}. */ public ModelMap getModel() { - return this.useRedirectModel ? this.redirectModel : this.model; + if (this.redirectModelEnabled && (this.redirectModel != null)) { + return this.redirectModel; + } + else { + return this.model; + } } /** - * Provide a model that may be used in case of a redirect. - * If {@link #useRedirectModel()} is called at any time after this method is - * called, the ModelAndViewContainer will switch to using the redirect model - * for all operations. Until then, the redirect model is not used. + * Provide an alternative model that may be prepared for a specific redirect + * case. To enable use of this model, {@link #setRedirectModelEnabled()} + * must also be called. */ public void setRedirectModel(ModelMap redirectModel) { this.redirectModel = redirectModel; } /** - * Make a switch internally from using the implicit model to using the - * redirect model provided earlier via {@link #setRedirectModel(ModelMap)}. - * If the redirect model was never set, this method has no effect. + * Signals that a redirect model provided via {@link #setRedirectModel} + * may be used if it was provided. */ - public void useRedirectModel() { - this.useRedirectModel = this.redirectModel != null; + public void setRedirectModelEnabled() { + this.redirectModelEnabled = true; } /**