You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Struts Newsgroup (@Basebeans.com)" <st...@basebeans.com> on 2002/05/30 19:55:02 UTC
struts and multi-valued database
Subject: struts and multi-valued database
From: "Wendy S" <we...@hotmail.com>
===
I'm not currently using Struts, but have been keeping an eye on it as a
possible framework for a web app.
I (think I) understand how it works with normal web forms-- all of the form
fields are known in advance, say 'Name' 'Phone Number' 'ZIP Code'. So then
it handles validation and "remembering" the form values if the same form
needs to be displayed again.
I'm less clear on how, once the data has been collected and validated, it
gets written to a database. Does Struts handle that part?
And now on to my issue. We use a multi-valued database (UniData). That
means that what you'd normally have in a sub-table, we have in a set of
associated multi-valued fields within the original record.
That means my web form has to "grow" in order to gather up several values
that are eventually going to land in a single field. I don't know how many
values there will be when I first write the form. So I start out with a
text area and an 'add' button. If they type something in and click 'add',
then I have to re-display the form with the value they typed, plus the blank
text area. So they put in five of these values... and now they want to
delete the third one.
Right now I'm creating read-only text areas with names like STAFF1, STAFF2,
STAFF3 and submit buttons out to the right with DELSTAFF1, DELSTAFF2,
DELSTAFF3. Then my Servlet looks to see if any request parameters start
with DELSTAFF, parses the number off the end, removes the value, and goes
back and displays the form again.
I'm desperate for a framework that can map HTML form elements to database
fields, but I don't know if there's anything available that understands
multi-values. In addition, most of these fields are not free text, but have
to be selected from a list that comes from the database, or must go off to a
lookup function to resolve a typed-in name to a list of possible records.
We do not have a JDBC driver for this database.
Thanks for any ideas!
--
Wendy
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: struts and multi-valued database
Posted by Adam Hardy <ad...@cyberspaceroad.com>.
Hi Wendy,
struts doesn't handle the DB access. The standard framework would be to
call business objects (the Model part of MVC) from your Action classes
(the control part of MVC) to do their stuff, including reading & writing
it to & from the DB, via a DB access layer or "object - relational
mapping framework" (as I've just learnt) for which there are frameworks
like JDO, Castor, OJB available.
So how are you accessing the DB if you don't have a JDBC driver? JNDI or
something?
For your situation with the html form, think over whether you are using
the right pattern for this, check out
http://martinfowler.com/isa/OR-mapping.html - direct mapping of the html
field to the DB field may not be the optimal solution - especially since
you have this Unidata database. I've not heard of it. Is it the one from
IBM?
Adam
Struts Newsgroup (@Basebeans.com) wrote:
>Subject: struts and multi-valued database
>From: "Wendy S" <we...@hotmail.com>
> ===
>I'm not currently using Struts, but have been keeping an eye on it as a
>possible framework for a web app.
>
>I (think I) understand how it works with normal web forms-- all of the form
>fields are known in advance, say 'Name' 'Phone Number' 'ZIP Code'. So then
>it handles validation and "remembering" the form values if the same form
>needs to be displayed again.
>
>I'm less clear on how, once the data has been collected and validated, it
>gets written to a database. Does Struts handle that part?
>
>And now on to my issue. We use a multi-valued database (UniData). That
>means that what you'd normally have in a sub-table, we have in a set of
>associated multi-valued fields within the original record.
>
>That means my web form has to "grow" in order to gather up several values
>that are eventually going to land in a single field. I don't know how many
>values there will be when I first write the form. So I start out with a
>text area and an 'add' button. If they type something in and click 'add',
>then I have to re-display the form with the value they typed, plus the blank
>text area. So they put in five of these values... and now they want to
>delete the third one.
>
>Right now I'm creating read-only text areas with names like STAFF1, STAFF2,
>STAFF3 and submit buttons out to the right with DELSTAFF1, DELSTAFF2,
>DELSTAFF3. Then my Servlet looks to see if any request parameters start
>with DELSTAFF, parses the number off the end, removes the value, and goes
>back and displays the form again.
>
>I'm desperate for a framework that can map HTML form elements to database
>fields, but I don't know if there's anything available that understands
>multi-values. In addition, most of these fields are not free text, but have
>to be selected from a list that comes from the database, or must go off to a
>lookup function to resolve a typed-in name to a list of possible records.
>We do not have a JDBC driver for this database.
>
>Thanks for any ideas!
>
>--
>Wendy
>
>
>
>--
>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>