struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Husted <hus...@apache.org>
Subject Re: FormBeans ... as an Interface.
Date Thu, 13 Jun 2002 09:38:39 GMT
John Yu wrote:
> Not dispute about this. But, you can view it from the other angle:
> 
> In my case, I want to use something from the model as the formbeans, not
> the other way round (as we all know having a model->view dependency is
> bad). However, because of the way formbean is designed in Struts, this ends
> up having the ActionForm class and the other dependent apis dragged into
> the model tier.
> 
> So, to paraphrase my question: "Does it make sense to modify Struts such
> that it allows other objects (e.g. from the model tier) to participate the
> role of formbeans but does not create an ugly model->view dependency?"
> 
> (The situation is like in Swing, a model object can implement a Listener
> interface and let the view components talk to them. This isn't regarded as
> a model->view coupling.)

For populating a form, you can use whatever JavaBean you like. So if you
give your model bean the expected form-bean name, the tags will use it 
without complaint. You can even populate the form using several 
different beans. Just specify the bean's attribute name in the tag.
The form's mapping's attribute name (whew!) is only a default.

The place where an ActionForm is truly expected is on the submit. But if
you use a Map-backed bean there, then you can accept whatever the form 
sends up. (Alternatively, for 1.0, ease the maintenance burden using a 
single coarse-grained bean with all the properites your application 
expects.)

To close the loop, add an adaptor to the business tier that can take a 
plain-vanilla map of Strings and populate your model bean. 

So, including the adaptor, we are talking about creating maybe two 
new classes. In 1.1, a BaseMapForm drops to one (the adaptor). And if 
your business tier can already cope with String maps, we've hit 
bottom at zero -:o)

-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services

--
To unsubscribe, e-mail:   <mailto:struts-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-dev-help@jakarta.apache.org>


Mime
View raw message