1. How to transform a ResultSet into a JavaBean (I think bean accesors don't have to be named as database columns...) without reinvent the wheel?
2. If I don't know how many columns the query returns (i.e. if the query is 'select * from ORACLE_VIEW') I supose I can use a DynaBean. Are there any other technique?
Thank you again, Guido.
Robert S. Sfeir wrote:
Yep, I agree with David. Your code will invariably be more usable and be more presentation layer friendly if you always return a Collection of some type. The Collection would contain beans of the object type you're working with. Further if you're using for example an ArrayList to populate a List, and later you decide you want to change it to something else for say performance reasons or what ever, you don't go busting the whole presentation layer because of it, since the presentation layer is working with a Collection and knows about nothing else. It is *sometimes* better to be as generic as possible with the underlying layers of your code, than hooking your presentation code in so tight that maintenance of the app is greatly affected.
On Friday, March 14, 2003, at 10:57 AM, David Graham wrote:
Both solution 1 and 2 are far better than using a ResultSet in a jsp. I usually use a Collection of JavaBeans.
David
From: Guido <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: Struts Users Mailing List <[EMAIL PROTECTED]> Subject: Data driven struts application Date: Fri, 14 Mar 2003 16:24:08 +0100
95% of my struts web apps follow this flow:
1. User selection in a JSP 2. Action class performs a SQL query 3. Return ActionForward to a new JSP that renders the query ResultSet
What is the best practice to show SQL query results (ResultSet) to the user? (I mean how communication between view and controller should be when I do extensive use of ResulSets)
Actually, we are including the ResultSet in the request :(, and processing it in the JSP (using a scriptlet). But I dont like this aproach very much, so I wonder if it would be better to:
+ solution 1. Use a RowSetDynaClass instead of the ResultSet.
+ solution 2. Use a JavaBean with getters and setters (maybe as database column names) and include a JavaBean collection in the request as a Value Object (?)
+ solution 3. I don't know... :(
Thank you very much, Guido.
PD. Is it better to use a collection of JavaBeans or use just one JavaBean whose properties return a collection??
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]