struts question: ok to use actionform as model?

T

tom

Hello,

I have a relatively simple application I am building using Struts 1.1.
I've just started using this framework so I'm not quite up to speed yet. My
question is in relation to the action forms: where should I put all my
business logic? For example, I've got a an action form with about 20 values
(ie get/set methods) and if they all validate properly I'd like to submit
this to a database.

What I have read here in this newsgroup is that in your Action you
should first get the formBean and then submit this to a javaBean. The
question I have is: should I write a new javaBean with exactly all the same
values as the formBean, and in that javaBean write the methods to write to a
database, and others I would like to implement such as "toXML()" method?
Let's say I take that approach--this brings me to my next question then: is
there an easy way to send all the "values" from the formBean to the
javaBean, or do I have for example like this:

customerForm f = (customerForm) form;
customerBean cb = new customerBean();

cb.setName(f.getName());
cb.setAddress(f.getAddress());

.... and so forth for about 20 or so values?

And lastly, is there an easy way to serialize the javaBean to XML?

Lots of questions here! Thank for any help!

-Tom
 
T

tom

Hello Joerg,

Many thanks for the help. I've decided to put the data access in the
bean itself... Yes I know I should probably use a separate object for the
data access but I think I'll leave that for my next version! :)

Regards,

-Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top