my program needs to set many variables posted from a very complex form
by working its way up a multi-tiered type hierarchy
and setting the relevant variables that apply at that level. ie:
Class A - variables aX,aY,aZ
Class B extends Class A - variables bX,bY,bZ
Class C extends Class B - variables cX,cY,cZ
at each level i recursively call the 'super' class method which
processes my request and sets the variables at that level.
this seems very longhand when i've got scores of variables to set from
my form.
is there a java pattern or neat way to handle this kind of scenario??
thanks, j
Chris Riesbeck - 20 Aug 2003 19:19 GMT
>my program needs to set many variables posted from a very complex form
>by working its way up a multi-tiered type hierarchy
[quoted text clipped - 8 lines]
>my form.
>is there a java pattern or neat way to handle this kind of scenario??
Are you saying your bean's have methods that take
a request object? They shouldn't. They should just
have simple properties, defined by get/set methods.
Where these store their data is up to you and
invisible to everyone else.
If you're in charge of the form, make the form's
field names match the properties, e.g.,
Class A defines getName/setName
Class B defines getSize/setSize, inherits A's properties
Class C defines getWeight/setWeight, inherits A's and B's properties
Make sure form has fields called "name", "size" and "weight"
-- spelling and case count. Then
<jsp:useBean id="myBean" class="myPackage.C" />
<jsp:setProperty name="myBean" property="*" />
will set all the properties in one brief bit of code.