You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matthew Ryan <ma...@matthewryan.info> on 2004/03/31 01:16:11 UTC

Abstraction one way, Direct access the next

I was wondering whether someone could tell me what is the best practice in
the following scenario.

Ok, performing data input I can encapsulate data in a Form Bean (whatever it
may be ActionForm, DynaActionForm,etc) pass it along to the Action mapped
through struts-config.xml, then at the Action class draw the line in the
sand between the web tier and services by using Service Locator pattern. For
me I think that is great. Abstraction in one direction.

In that Action I can receive back data, attach it to the Request object and
send it along to the 'target' JSP. That is not too bad either, the JSP knows
the Request object and the collection that comes with it can be dealt with
using Struts or custom tags. So far so good.

However, what if I am coming to a JSP which does not follow an action yet
must display data of some sought from a data source?

Ok, there are JavaBeans. I instantiate an instance of a JavaBean, call a
method 'public List getXXXX()', and iterate over what I get back.

The use of the Service Locator pattern, or even if I went to IoC in one
direction seems so elegant. Can anyway tell me what is a better means in the
case where no Action has been initiated?

Thanks

Matthew


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org