An interface to support model component of the Struts2 MVC architecture.
An interface to support model component of the Struts2 MVC architecture. This interface should implement action classes which applying a user model as a generic parameter. If an action class implements the interface ModelDriven
then it needs to return an object from the getModel()
method. Struts2 will then populate the fields of this object with the request parameters, and this object will be placed on top
of the valueStack
once the action is executed. Validation will also be performed on this model object, instead of the action.
ModelDriven
action uses it's own interceptor modelDriven
which included in the defaultStack
interceptor stack. Thus every action that uses that stack invokes this interceptor to check if an action is instance of ModelDriven
then applying a model to it.
There's also a ScopedModelDriven
interface that is used for models that has lifecycle for the specified scope.