SPR-6464 Uncommitted file from the last commit.
This commit is contained in:
parent
baea01ac90
commit
00ff018b39
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue