Torque allows you to define you mappings in a single xml file and you can generate all the required model classes and the sql.

There are a few compromises like i haven't found that it supports inheritance do life is easier if you just have repeating fields across tables, thus not very rationalized. But really who cares, a few DBA's i guess. The inheritance could be supported, I'm still looking into it.

You can use the generated classes straight into your formbeans but I've used a bean tier. And you dont have to do any SQL. So i can be more selective when to write to the db, also not doing so breaks with a lot of what struts is designed for. But you can it will make your app harder to decouple from the model, so whether this is a huge issue is down to you.

Most things work with torque but I warn you its not as well documented, and list attended as well as the struts project.

A bit non MVC but you can use the torque objects straight into your DynaForm definition..

<form-property name="applicant" type="com.sparrow.om.Applicant" />

Generating fields in jsp's I don't know. You could change the velocity templates to generate your beans and jsp i guess. But dont those IDE things do all that?

Cheers Mark


On Wednesday, August 13, 2003, at 07:02 PM, Andy Cheng wrote:


Basically I am just wondering if the process can be a bit more
interesting. I always:
1. Get values from the JSPs and the values (Strings) are used to set the
ActionForm ie String to String copying.
2. In the Action class, I get the values from the ActionForm, and
convert them to the appropriate types, and insert them into beans using
the beans' setter methods.
3. From the objects I have, I will write PreparedStatements (with many
?? in the SQL), and set the values in the order of the question marks.
I have to do this for INSERT, and UPDATE.


On the reverse, I have to get the data from database, getting values
from ResultSets, and insert into beans, then from the beans I feed them
back to the JSPs for display.

This is a very boring thing to do, and it does not require much skill as
well. I am just wondering if there is a way of speeding up:
1. Conversion between ActionForm (Strings) to Beans (Typed)
2. Generate ActionForms
3. Generate the fields in the the JSPs
4. Generate the SQL statements.


I know I am being very very greedy here, but if there is no other way
than being a typist for days, I would rather write a small program to do
all these. I have read Castor JDO could help generating code, but I
have to read and understand more before I know if it is helping me.
Thanks


Andy

-----Original Message-----
From: Wendy Smoak [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 14, 2003 12:49 AM
To: 'Struts Users Mailing List'
Subject: RE: database - bean - form, what is the best way to do it?

When doing struts, I am always loading or saving data to a bean (or a
list
of beans)
and then display it to the form. Is there a ways to make this process
very automatic,
like writing a mapping file, and then everything is done? I spent in
the
past 2 full
days just keep doing this kind of mapping and it is getting me real
crazy.
Thanks

Take a look at the struts-example webapp.  I do this same thing in my
Struts
app-- load from the database into a bean, then use
BeanUtils.copyProperties(...) to move the values over to the form, then
display it.  I use Dynamic forms, so the form properties are defined in
struts-config.xml, which gets me out of writing the get/set methods for
the
form bean.

What part of it is giving you problems?

--
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University, PA, IRM



---------------------------------------------------------------------
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]



Reply via email to