Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

(Struts) Any class that can do introspection for me?

 
Junilu Lacar
Bartender
Posts: 7466
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am currently developing an application using Struts. I have chosen to move the data from my ActionForm to a DataObject. This has worked pretty well so far because data that must be saved at the same time can come from multiple data entry screens. With the DataObject, I can just stuff values from the ActionForm and pass the DataObject around until it is time to save it. It has also helped me keep the API to the persistence layer relatively simple as I usually just pass a DataObject to/from it.
Each of my ActionForm classes has a copyTo(DataObject) and copyFrom(DataObject) method. The methods basically do what Struts does with the JSP/request and the ActionForm: moves values of attributes between the two.
Questions:
1. What do you think of the approach I am using?
2. Are there any issues that I may encounter later by using this approach?
3. I am currently manually copying fields to and from the ActionForm and DataObject. This is getting more unwieldy as I add more fields to the ActionForm and DataObject. Is there a way to automate this process without having to write my own reflection-based utility class? That is, is there a class/method in Struts that can do this? (I could dig around the Struts source and see for myself but if anyone knows offhand, it would save me some time and effort )
TIA!
Junilu
[This message has been edited by JUNILU LACAR (edited November 03, 2001).]
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by JUNILU LACAR:
I am currently developing an application using Struts. I have chosen to move the data from my ActionForm to a DataObject. This has worked pretty well so far because data that must be saved at the same time can come from multiple data entry screens. With the DataObject, I can just stuff values from the ActionForm and pass the DataObject around until it is time to save it. It has also helped me keep the API to the persistence layer relatively simple as I usually just pass a DataObject to/from it.
Each of my ActionForm classes has a copyTo(DataObject) and copyFrom(DataObject) method. The methods basically do what Struts does with the JSP/request and the ActionForm: moves values of attributes between the two.
Questions:
1. What do you think of the approach I am using?
2. Are there any issues that I may encounter later by using this approach?
3. I am currently manually copying fields to and from the ActionForm and DataObject. This is getting more unwieldy as I add more fields to the ActionForm and DataObject. Is there a way to automate this process without having to write my own reflection-based utility class? That is, is there a class/method in Struts that can do this? (I could dig around the Struts source and see for myself but if anyone knows offhand, it would save me some time and effort )
TIA!
Junilu
[This message has been edited by JUNILU LACAR (edited November 03, 2001).]


Hi Junilu. I think your approach is fine -- it's exactly what I've done in my own struts code and in the articles on struts that I wrote.
I don't think there's anything in struts like you describe. Sounds like you're going to have to write a utility class to me...
Kyle

------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic