struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject RE: Design Patterns/Examples
Date Wed, 29 Jan 2003 08:48:06 GMT
We have used folowing approach..

To access db , we use DAO pattern(refer to Sun's blue prints for more 
details).The DAOs return value objects And all calls to the DAO must go through 
service layer..

So in action classes u get Instance of appropriate service from service factory 
and call the corresponding method..So all the data base access logic  and 
conversion of result set to u r value beans is in service layer.(We have used 
converter classer for the same..One converter per Value bean...)
Also as service factory is used, u can pretty much change ur servie 
implementation with out afecting the struts layer.

So on struts side ,the action clsses are pretty much simple .They just delegate 
the request.
In action, we get the data from request.And validate the data and if any 
validation errors, send back to the user.Each form contains value beans as 
thier attributes.So the data from jsps is automatically populated in the form 
beans and the action just has to cast the form bean to appropiate type and call 
getBean or beanList as the case may be..

And as u said, the most important part is how we handle conversion of data from 
primitives to string and vice versa.On form bean, all beans are 
StringBeans...So for each ValueBean we have a corresdpondign String bean..And 
the StringBEan has a method getBean which returns the corresponding valueBean 
after performing the conversions from String to primitive type.Similarly on 
each ValueBEan we have a getStringBEan which performs the conversion from 
primitive to String type.And we have a Utility class ParsingUtils which has all 
the conversion methods...

The most important part is we use CodeGeneration using XSLT to create the value 
BEans,DAOs,COnverters for value beans and the String beans.And for the code 
generation , we use an XML which describes which StroedProc is caled and the 
field names etc etc.So all this conversion methods (getStringBean and 
getBean)are also auto generated.And as we have utility methoda in 
PArsingUtils,this is nto at all difficult.So we dont spend any time at all 
coding data conversion or data access layer.All we need to do is write jsps and 
action classes to delegate...

Hope this is not too lengthy or confusing...I know there are some issues like 
too many Objects are  created(for each bean, a correspondign string bean is 
created etc etc..)but we have found a satisfactory performance for our load 

If any body s interrested, i can give sample code for code generation as well..

hope this helps,

-----Original Message-----
From: pat.quinn2009 []
Sent: Tuesday, January 28, 2003 9:21 PM
To: struts-user
Subject: Design Patterns/Examples

Hi Guys,

Any one know of some design patterns or examples i could use with struts. I 
want to access a database(Value Objects) allow the user to change the VO 
data, perform some business validation and update the database. I’d like 
some pointers also when working with form beans and vo object whats the best 
way to transfer data between them... should i use vo’s as instance variable 
instead form bean... if so how will i handle java primitives like double’s 

I'm not looking for the answers to all the above but i'd like to review a 
pattern or example which demonstrates the best approach for the above.

I have my own ideas but would like to look over some design 
patterns/examples before commencing this work.



Add photos to your messages with MSN 8. Get 2 months FREE*.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message