Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Code Block
public class ExampleAction extends ActionSupport {

	@In(scope = ScopeType.SESSION, value = ModelRepo.DOMAIN_MODEL)
	@Out(scope = ScopeType.SESSION, value = ModelRepo.DOMAIN_MODEL)
	private ExampleBean exampleBean;

	...

	public String edit() {
		...
		return SUCCESS;
	}

	public String save() {
		...
		return SUCCESS;
	}
}

That's all. After the edit, the domain model will be stored in the session. On the save, the model will be restored before the new values are applied.

Model Repository vs. params-prepare-params

An alternative to the model repository is to use the params-prepare-params interceptor stack. The params-prepare-params interceptor stack requires the object you are editing to be re-read from the database. In cases where optimistic locking is used, this completely circumvents the version field. In these cases, the originally read object should be used when saving the object.