|
|
@ -40,7 +40,7 @@ public class ModelAndViewContainer { |
|
|
|
|
|
|
|
|
|
|
|
private ModelMap redirectModel; |
|
|
|
private ModelMap redirectModel; |
|
|
|
|
|
|
|
|
|
|
|
private boolean useRedirectModel = false; |
|
|
|
private boolean redirectModelEnabled; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new instance. |
|
|
|
* Create a new instance. |
|
|
@ -108,35 +108,32 @@ public class ModelAndViewContainer { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return the internal model currently in use. Normally this is the |
|
|
|
* Return the model to use, never {@code null}. |
|
|
|
* 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}. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ModelMap getModel() { |
|
|
|
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. |
|
|
|
* Provide an alternative model that may be prepared for a specific redirect |
|
|
|
* If {@link #useRedirectModel()} is called at any time after this method is |
|
|
|
* case. To enable use of this model, {@link #setRedirectModelEnabled()} |
|
|
|
* called, the ModelAndViewContainer will switch to using the redirect model |
|
|
|
* must also be called. |
|
|
|
* for all operations. Until then, the redirect model is not used. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setRedirectModel(ModelMap redirectModel) { |
|
|
|
public void setRedirectModel(ModelMap redirectModel) { |
|
|
|
this.redirectModel = redirectModel; |
|
|
|
this.redirectModel = redirectModel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Make a switch internally from using the implicit model to using the |
|
|
|
* Signals that a redirect model provided via {@link #setRedirectModel} |
|
|
|
* redirect model provided earlier via {@link #setRedirectModel(ModelMap)}. |
|
|
|
* may be used if it was provided. |
|
|
|
* If the redirect model was never set, this method has no effect. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void useRedirectModel() { |
|
|
|
public void setRedirectModelEnabled() { |
|
|
|
this.useRedirectModel = this.redirectModel != null; |
|
|
|
this.redirectModelEnabled = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|