Re: Struts and Displaying data from a database
I had this question the other day and was referred to Hibernate (http://www.hibernate.org) by David Friedman. The other name that cam up was ibatis. I chose hibernate and used this tutorial to help figure it out: http://homepage.mac.com/edahand/projects/java/example1.html On Tue, 2 Nov 2004 13:56:54 -0500, dbm_mailinglist [EMAIL PROTECTED] wrote: Hello, I'm a complete newbie to Struts. I know how to use Struts to build forms and submit them, but how do I just display data from a database? I want a screen that just displays data from a sql command to a database and displays the results in a html table. Do I use ActionForm even though I don't have a form? I haven't been able to find any good examples on the web. Any ideas? Thank you! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts and Displaying data from a database
1. http://www.w3.org/TR/REC-html40/struct/tables.html 2. http://www.displaytag.org/index.jsp dbm_mailinglist [EMAIL PROTECTED] 11/02/2004 01:56 PM Please respond to Struts Users Mailing List [EMAIL PROTECTED] To [EMAIL PROTECTED] cc Subject Struts and Displaying data from a database Hello, I'm a complete newbie to Struts. I know how to use Struts to build forms and submit them, but how do I just display data from a database? I want a screen that just displays data from a sql command to a database and displays the results in a html table. Do I use ActionForm even though I don't have a form? I haven't been able to find any good examples on the web. Any ideas? Thank you! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Struts and Displaying data from a database
I guess that's where I get lost. What does the bean return so that it can display multiple rows in the JSTL/JSP? I guess the type of the 'getter' would be some type that allowed you to loop through the dataan array maybe? Do you know if there are any examples on the web? I'm trying to stick to just JSP/JSTL/Servlets/Java and trying to steer away from additional tools like Hibernate. Thank you much! -Original Message- From: Slattery, Tim - BLS [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 02, 2004 2:02 PM To: 'Struts Users Mailing List' Subject: RE: Struts and Displaying data from a database I'm a complete newbie to Struts. I know how to use Struts to build forms and submit them, but how do I just display data from a database? I want a screen that just displays data from a sql command to a database and displays the results in a html table. Do I use ActionForm even though I don't have a form? I haven't been able to find any good examples on the web. You don't necessarily need an ActionForm for this, but you do need a JavaBean to hold the data you want to display. To display it on the page, use JSTL c:out ... tags. -- Tim Slattery [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]
RE: Struts and Displaying data from a database
From: dbm_mailinglist [mailto:[EMAIL PROTECTED] Subject: RE: Struts and Displaying data from a database I guess that's where I get lost. What does the bean return so that it can display multiple rows in the JSTL/JSP? I guess the type of the 'getter' would be some type that allowed you to loop through the dataan array maybe? One of the bean's properties would yield a collection of (other) beans. Each bean in that collection would correspond to one row of the HTML table. You can use c:forEach... to iterate over that collection. Another poster mentioned the DisplayTag taglib, which is very good for this sort of thing (www.displaytag.org). -- Tim Slattery [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Struts and Displaying data from a database
Have the business logic (where ever it may reside) return a collection of JavaBean. You can simply place the collection in some scope (request, session, etc..) and render it on the JSP page using JSTL (for-each) or Struts iterate tag. You basically define an action mapping which will be invoked before displaying the .jsp page. The action delegates to the business logic (which does the work of retrieving the data) and then places the returned collection in some scope. The action then forwards to the appropriate .jsp page. Does this help? robert -Original Message- From: dbm_mailinglist [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 02, 2004 2:25 PM To: Struts Users Mailing List Subject: RE: Struts and Displaying data from a database I guess that's where I get lost. What does the bean return so that it can display multiple rows in the JSTL/JSP? I guess the type of the 'getter' would be some type that allowed you to loop through the dataan array maybe? Do you know if there are any examples on the web? I'm trying to stick to just JSP/JSTL/Servlets/Java and trying to steer away from additional tools like Hibernate. Thank you much! -Original Message- From: Slattery, Tim - BLS [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 02, 2004 2:02 PM To: 'Struts Users Mailing List' Subject: RE: Struts and Displaying data from a database I'm a complete newbie to Struts. I know how to use Struts to build forms and submit them, but how do I just display data from a database? I want a screen that just displays data from a sql command to a database and displays the results in a html table. Do I use ActionForm even though I don't have a form? I haven't been able to find any good examples on the web. You don't necessarily need an ActionForm for this, but you do need a JavaBean to hold the data you want to display. To display it on the page, use JSTL c:out ... tags. -- Tim Slattery [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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]