Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / August 2003

Tip: Looking for answers? Try searching our database.

Recursive variable setting up the bean type hierarchy

Thread view: 
John McC - 20 Aug 2003 16:47 GMT
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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.