struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Raible <matt_rai...@yahoo.com>
Subject RE: Automation options between ActionForm and Value Object?
Date Mon, 03 Dec 2001 15:22:25 GMT
I've used Jon's suggestion below and it works very nicely.  In my applications,
I create a BaseFormBean that has an action property.  Then in my FormBean's
that extend this class, I have a getter/setter for the VO.  Works really slick.
 In my Edit Action classes, I populate the VO from an EJB and then set it on
the form, and display.  In my Save Action classes, I get the VO from the form
and persist it to an EJB.

There might be an easier way, but this has worked nicely for me.

Matt

--- "Jon.Ridgway" <Jon.Ridgway@upco.co.uk> wrote:
> Hi Allen,
> 
> Probably the easiest approach would be to use the utility provided by Struts
> (now in the commons project):
> 
> org.apache.commons.beanutils.PropertyUtils.
> 
> Search the latest source of Struts and you will find several examples of its
> use. Another useful tip is to reference your vo - via you struts form
> directly on you JSP, eg:
> 
> <bean:write name="<form name>" property="<vo getter name>.<vo getter>"/>
> 
> So with a vo called personVO, which has a firstname property and associated
> getter and is accssed via the getPersonVO method on our form bean you could
> use:
> 
> <bean:write name="<form name> property="personVO.firstname"/>
> 
> This works with all Struts tags that have a property attribute.
> 
> Jon.
> 
> -----Original Message-----
> From: Allen M. Servedio [mailto:allen.servedio@gtri.gatech.edu] 
> Sent: 03 December 2001 13:43
> To: struts-user@jakarta.apache.org
> Subject: Automation options between ActionForm and Value Object?
> 
> Hi All,
> 
> Though I still have much existing material to read in the STRUTS mailing 
> lists (thanks again for your help Jon!), I have come across three 
> interesting solutions to dealing with automating or centralizing the 
> translation of data from Action Forms (presentation layer) to Value Objects 
> (business layer) and back again. Here are the three approaches:
> 
> Translation Pattern: 
> http://www-106.ibm.com/developerworks/library/j-jsppatt/?dwzone=java&dwzone=
> ibm
> 
> Using Property Editors: 
> http://www.onjava.com/pub/a/onjava/2001/11/07/jsp12.html?page=2
> 
> Using Code Generation: 
> http://www.javaworld.com/javaworld/jw-11-2001/jw-1102-codegen.html
> 
> The current one that I have seen referred to in the mailing lists is using 
> Reflection (which still may easily solve this in most cases) or some type 
> of mapper driven by XML setup info. Here are the mailing list threads that 
> I have found on it so far:
> http://www.mail-archive.com/struts-user@jakarta.apache.org/msg18315.html
> http://www.mail-archive.com/struts-user@jakarta.apache.org/msg18373.html 
> (an answer from Ted related to msg18315)
> http://archive.covalent.net/jakarta/struts-dev/2000/10/0135.xml
> http://www.mail-archive.com/struts-user@jakarta.apache.org/msg05437.html
> 
> Two other related patterns that I have found are the:
> View Helper: 
> http://developer.java.sun.com/developer/restricted/patterns/ViewHelper.html
> Dynamic Value Object: 
> http://www.theserverside.com/patterns/thread.jsp?thread_id=2722
> 
> I was curious what people thought of these solutions and what other 
> solutions they had come up with.
> 
> This is an area that I really want to automate and that I really want to 
> have a couple of solutions for (since it could generate a great deal of 
> code that I REALLY don't want to have to rework if I find that the solution 
> is no good).
> 
> Thanks for your thoughts and comments!
> Allen
> 
> 
> --
> To unsubscribe, e-mail:
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:struts-user-help@jakarta.apache.org>
> 
> --
> To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com

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


Mime
View raw message