You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mike Whittaker <mi...@ntlworld.com> on 2003/05/18 19:43:45 UTC

Getting Action Form data into the Model layer, was '...doppelgangers'

partly in reply to Vic C. but any one please...

>I am not sure if Dyna this, that and other is always a good idea. I like
>using form beans instead of Dyna this and that, since they allow me to
>unit test and reuse the beans.

Yes I'm using concrete form beans, just thought it best to copy them
dynamically, why recode basically the same things again?

>
>I am not sure what your business classes are, so I can't comment on it.
>The approach I like is to have form beans have a DAO helper.
>Also, sometimes you want to reuse you Struts code, for example
>validation comes to mind.
>

Looking at your archive comments re DAO helper, I think you are talking
about prepopulating forms from existing data.  This is not my concern.

>You could use bean utils to copy from one set of beans to another maybe
>in your case, I use a list backed formbean.

Haven't a clue what a list backed formbean is.

>Don't worry about best thing to do,  good enough is good enough. Since
>MVC separates the layers, it is hard to go wrong.

Basically I need to get the request parameter data in to the business layer.

All the turorial examples I've seen have a model layer that is just the
Action classes!!

My application is very simple, but I do at least want to be able to reuse
the business classes with different data storage and View architecture
layers.

Using form beans in the business layer surely contravenes MVC massively! the
ActionForm reset method takes an HttpServletRequest!!

Next thought was to leave the Form beans just for their purpose (Forms!).
And use the servlet level Parameters, extracted as a Map.  Before I got into
Struts, I'd written a wrapper around this Map that took out "" and nulls,
and filtered SQL sensitive characters.  I thought I'd have another look at
using this, subclassing ActionServlet, and adding this wrapped Map into the
request attributes, to be available to all Actions.
This approach doesn't seem very Stuts!

So back to the original plan, copy the Form beans dynamically and use them.
But then I lose all my SQL filtering, which was so neat & simple.
Another option I suppose is to make the form beans implement an interface,
but coding the form beans is dull enough without duplicating it with
interfaces (cut & paste will help though).

How can I globally refactor in the SQL sensitive character filtering in
Struts?

I've seen a BeanUtils method that populates a bean from a map, I could use
my Map subclass with its SQL filtering with this?  But all this seems to
have relied on a lot of research on my part for something I'd expect to be
so common place I'd have read a solution earlier!


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