Question

I'm not concerned about making a useful project under Struts2, only, but a well structured one, too. I have a bean called Custormer, in which there are necessary attributes and their getters and setters.. I wonder then where I should build the different manipulations of the Custormer bean, such as Subscribe, Upgrade, ... Should it be in the Model class or the Action class? Also, I don't understand exactly for what the Model-Driven class is needed.. Thank you a lot guys :)

Was it helpful?

Solution

Neither, those likely belong in service classes–but it's impossible to tell from your description. What actually happens when a user subscribes? Upgrades?

Action classes should be essentially nothing more than glue between the web and business layers, marshaling data, handling success/error conditions from both layers, etc.

Model classes are just that–models of your business domain. The nature of those models can vary wildly between domains, design/architecture methodologies, etc. Where business functionality lies can vary just as wildly. Service layers, DDD, etc. may all handle such functionality.

It should not, however, be implemented directly by actions. Rather actions should delegate to a service layer, the models, etc. In other words, an action shouldn't directly update a database field to indicate a user has upgraded. The web layer just directs site users around.

ModelDriven is just an abstraction that says that instead of putting the action on the top of the value stack (e.g., form properties will be set on action properties), an instance of the model will be on the top of the stack (e.g., form properties will be set on the model instance).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top