Struts, JSP, Servlets and dB

2001-10-26 Thread Daniel WAMARA

Hi,

no good answer has been given to me thru all the websites I went to but I 
should now have to ask my question here I think : I'm brand new in Struts' 
world because I've been hired by a company using it.

Having worked before with servlets where querying databases where a matter 
of SQL statements, I'm not a bit lost : all the examples I've seen were 
using kinda XML databases but I now have to make a short application to 
see that I'm a bit good in Struts before beginning my real project next 
week.

I would like to know if I can use some normal SQL statements in my Form 
objects extending the ActionForm class ?

Writing the config-struts.xml file, writing the form objects, writing the 
lines of the Actions are not a problem because I now have a good look over 
it but how could I use normal databases or tables like I was doing before 
with servlets, like defining the driver, getting the connection, making 
statements and so on...

I was a bit long but it was for a good explanation.

Thanks for helping,

Daniel WAMARA

Frankfurt/Main, Germany

_
Téléchargez MSN Explorer gratuitement à l'adresse 
http://explorer.msn.fr/intl.asp




Re: Struts, JSP, Servlets and dB

2001-10-26 Thread Ted Husted

Extending the ActionForm to handle the SQL statements might be a bit
much. 

People often handle data access directly from the Action. The Action
pulls the data out of the ActionForm, puts it into a SQL query, and then
puts the result back into the ActionForm, or an ArrayList. Just as
people have often done with conventional servlets. 

Though, this doesn't provide the best separation of controller and
model.

Right now, I'm working on a slightly different approach that keeps the
data access seperate from the rest the Action. I specify a data access
class in the ActionMapping (using the parameter property). The data
access class is a model bean with a standard method for calling a SQL
query. The model bean looks a lot like the ActionForm bean, except that
it uses native types. The model bean is subclassed for each query. All
the Action does is populate the model bean, and call its query method
(execute). (As a convenience, my model beans can populate themselves
using reflection, so this becomes one call - execute(form).) The data
access class then returns a list of beans generated by the query. 

The sample application is Artimus, which uses the Scaffold package.

http://husted.com/struts/resources.htm#new

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/


Daniel WAMARA wrote:
 
 Hi,
 
 no good answer has been given to me thru all the websites I went to but I
 should now have to ask my question here I think : I'm brand new in Struts'
 world because I've been hired by a company using it.
 
 Having worked before with servlets where querying databases where a matter
 of SQL statements, I'm not a bit lost : all the examples I've seen were
 using kinda XML databases but I now have to make a short application to
 see that I'm a bit good in Struts before beginning my real project next
 week.
 
 I would like to know if I can use some normal SQL statements in my Form
 objects extending the ActionForm class ?
 
 Writing the config-struts.xml file, writing the form objects, writing the
 lines of the Actions are not a problem because I now have a good look over
 it but how could I use normal databases or tables like I was doing before
 with servlets, like defining the driver, getting the connection, making
 statements and so on...
 
 I was a bit long but it was for a good explanation.
 
 Thanks for helping,
 
 Daniel WAMARA
 
 Frankfurt/Main, Germany
 
 _
 Téléchargez MSN Explorer gratuitement à l'adresse
 http://explorer.msn.fr/intl.asp