You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by MARK NICHOLS <DH...@dhs.state.il.us> on 2002/03/04 14:20:58 UTC

Re: Best way to deal with Form object String parameters into another bean?

You can search to your heart's content here:

http://www.mail-archive.com/struts-user@jakarta.apache.org/


___________________________________
- mark h. nichols
- dhsv022 at dhs dot state dot il dot us 

"Ooo. They've got the Internet on computers now." - Homer Simpson 

>>> maillist@reumann.net 03/03/02 12:54AM >>>
I've just begun studying the struts examples and reading the
documentation and have waited a bit before I posted this question. I
am a newbie to struts but have done some searching and looking at
examples but still need some more help.

Before I begin it would be best if I ask my questions in the context
of a simple example. Lets say we have a simple Employee Administration
application where there might a form that allows you to enter or edit
employee information.

Now first off, it would seem likely using struts that I would have an
EmployeeForm object and then maybe two action objects such as
AddEmployee and EditEmployee (or possibly just one of them that can do
all the tasks).

Now it would seem like for most situations you would have an
EmployeeForm object and also an EmployeeBean. Now the question I have
is at what point would you transfer the info in the EmployeeForm
object to the EmployeeBean? Should this be done in the AddAction and
then the AddAction might call a method in the business tier of
doInsert( EmployeeBean employee )? Or do you possibly just pass all
the form parameters off to a doInsert() method as arguments and then
in the business tier doInsert() method do what you have to do with
them.

I'm having some trouble seeing how they manage this with the
SaveSubscriptionAction in the strut example. It looks like they are
using PropertyUtils.copyProperties(subscription, subform); to get the
information from the subform into a subscription object. (I admit I
haven't studied using this PropertyUtils objects so I'll have to look
into it). However, I'm still just generally confused about the best
way to get the values in my EmployeeForm object which are all Strings
into the correct format for being entered into a database.

Before looking into this struts framework, my controler servlet would
pass the request object off to the appropriate Action class which in
turn might hand the request object to another class method that would
create an EmployeeBean from the request object parameters. Than after
that EmployeeBean was returned the appropriate method in the business
logic tier was called such as businessTierObject.addEmployee(
employeeBean );

The validation abilities using FormObjects seem really powerful, yet
I'm still stuck on where to do all my casting and conversions of the
String request parameters into the proper data types (ie..birth date
as a String to birthDate as a java.util.Date, ss# as a String to an
int, etc).  I guess my basic question is where should this process
take place? Do you pass the whole Form object in the Action object off
to the business tier and let that level deal with creating the correct
format of the request parameters?

I'm sure this has all been brought up and/or answered many times so I
appreciate your patience. Is there a way I can search through past
posts to this mailing list?

Thanks for any help.


--

Rick

mailto:maillist@reumann.net 

"I can't stand cheap people. It makes me real mad when someone says
something like, 'Hey, when are you going to pay me that $100 you owe
me?' or 'Do you have that $50 you borrowed?' Man, quit being so
cheap!"
  -Jack Handey


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>