Originally posted by karl koch:
is it common to put the business logic inside the action classes (as in many examples) or should the action just call the apropriate methods of the business logic ?
if the actions just call methods of the b-logic, then how do they get a reference to it ? whats a common way to do this (since the perform method and the constructor of the aciton is fixed) ?
Hi Karl,
I'm fairly new to struts myself, but I'll let you know what I've learned from my research/coding thus far:
It depends on who you ask, but there seems to be a consensus that the Action classes are typically considered part of the Controller, not the Model, so it is best not to place business logic in the Actions.
From what I have seen, the recommended course of action is to code to an interface and use a
pattern such as a Facade or a Factory to gain references to your business tier classes. This will effectively decouple your Model from your Controller, which is what you want with MVC2. The methods exposed by the interface to the business logic can(and often do) return Value Objects representing the state of the business tier, which your Views then display.
These are my impressions of what I have read and the strategy I employ in my code, somebody please feel free to correct me here if I am giving bad information!
E