Assuming your design is something like this:
- Http request passed to Action Component.
- Action Component accesses Business Component.
- something generates View component based on Business Component.
- Http request passed from Action Component to view (perhaps a JSP).
If want the Action Component to be agnostic to step 3, then make the Business Component generate the View Component. Here is a javaish, approach:
package some.model.package;
class final ViewObject
{
private String something;
public ViewObject(final String something)
{
this.something = something;
}
private String getSomething()
{
return something;
}
}
interface Business
{
Object doBusinessStuff(... HttpServletRequest and other stuff...);
}
package some.model.package;
class final BusinessObject
implements Business
{
... business stuff ...
private String determineSomethingValue()
{
String returnValue;
returnValue = ... determine the value of something ...
return returnValue;
}
private Object getViewObject()
{
ViewObject returnValue;
String somethingValue;
somethingValue = determineSomethingValue();
returnValue = new ViewObject(somethingValue);
return returnValue;
}
Object doBusinessStuff(... HttpServletRequest and other stuff...)
{
... do stuff based on inputs ...
return getViewObject();
}
}
package some.control.package;
class final ActionObject
{
public somehting processHttpRequest(HttpRequest request, ...other parameters...)
{
Business businessObject = ... get the business object from somewhere ...
Object viewObject;
viewObject = businessObject.doBusinessStuff();
request.setAttribute("view object name", viewObject);
}
}