On 9/20/05, Dave Newton <[EMAIL PROTECTED]> wrote:
> Michael Jouravlev wrote:
> 
> >Or... you can set Product object as nested property of an ActionForm,
> >and set ActionForm's scope to "session". The result is the same, but
> >seems more natural to me. You can render Product on JSP page, or
> >populate it from input (Struts will do it for you).
> >
> >
> True.
> 
> But then you've tied at least part of your app to Struts, which makes
> standalone unit testing more difficult than (I feel ;) it needs to be!
> With the decoupling you can trivially test business logic that depends
> on state.

It still is decoupled, only nested ;-) Nesting it in ActionForm you
keep its state and get it populated from request. You can do the same
for unit test: keep the state and populate.

A little bit offtopic: say you have a New User Registration form. Your
business object for userinfo contains username and password, but does
not contain retyped password, because retyped password is not part of
business data, it is needed for input verification only. How would you
test "Adding a new user" use case without ActionForm or additional
wrapper around your Accout object? So, Account object still has to be
tied to something else, if not to ActionForm, then to some other
view/model wrapper.

This is what I implemented about a year ago: a wrapper around business
object, which contains business object itself and UI-only fields plus
error messages relevant to this object only. Worked great, so I
basically use ActionForm only as hollow container, as a facilitator to
populate fields with input data, because Struts populates properties
of ActionForm only.

Michael.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to