Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The model repository is designed to be used for the typical edit/save use case that many web applications must handle. The use case begins with the use user choosing to edit an object in the system. The system loads the given object from the database and displays the object for the user to edit. At the same time, the object should be stored in the session so it can be retrieved later. Once the user is finished editing the object, the user clicks the save button and the page is submited back to the application. At this point, the object is restored from the session and the new values are applied to the newly restored object. Then the object is persisted to the database, so the new values are not lost.

...

Now simply annotate your domain model with an @In and @Out session annotation using the string constant from above as the session key.:

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;

	...

}

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.