Versions Compared

Key

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

...

This functionality can be implemented very easily with the scope plugin. The first step is to define a place to store the model in the session. This key is used for all actions. Any previous value is overwritten with the new value for the current action. This ensures that the session is not filled of with random values from each action.

Here is the interface that hold our global session key for all action models:

Code Block
/**
 * The location in the session where the domain model is stored between an edit
 * and a save.
 */
public interface ModelRepo {
	/**
	 * The session key where domain model is stored.
	 */
	public static String DOMAIN_MODEL = "DOMAIN_MODEL";
}

Now simply annotate your domain model with

Code Block
public class SurveyActionExampleAction extends ActionSupport {

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

	...
}