Re: [OT] Create/Edit Form

2005-07-28 Thread Emmanouil Batsis


You need an identifier to update an object, which usually corresponds to 
a PK in your database.  When the identifier is not present or does not 
correspond to a persisted entry, you probably want to create.


hth,

Manos

Andrew Tomaka wrote:


Hey all,

The following is pretty hard to understand.  I'm no good at describing
my problems and wasn't sure how to explain it.  Hopefully, someone
will get what I'm attempting to say

I'm working on a screen that allows a user to dynamically add rows via
Javascript. I then have have a form that contains a list of beans that
stores the data (but that's really beside the point).

My issue comes with the storage of this information.  The form can
either be a blank form or it can be preloaded with other information
depending on whether the record exists or not.  If it is preloaded,
the user can edit the existing rows or add new rows.  The problem
comes when I need to update the database.  When the user hits the save
button, it submits all the information, but I have no way of telling
if a specific row was edited or created. Because of this, I don't know
whether to make an UPDATE query or an INSERT query.  Can anyone think
of a creative way to do this without adding an extra query for each
row?

Any insight would be greatly appreciated!

Thanks,
~ Andrew Tomaka

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



Re: [OT] Create/Edit Form

2005-07-27 Thread Andrew Tomaka
I agree fully, but, unfortunately, I can't do a whole lot about it. 
The databases were set up before I started on the project and I guess
the DBA was pretty hard nosed about changing from how he wanted it. 
Oh well.

~ Andrew Tomaka



On 7/27/05, Michael Jouravlev <[EMAIL PROTECTED]> wrote:
> On 7/27/05, Andrew Tomaka <[EMAIL PROTECTED]> wrote:
> > I realized the
> > problem was actually a bit more complex than I was making it.  The
> > database table I am editing requires two primary keys to make an entry
> > unique (I'm a firm believer in a single PRImary key, but it wasn't my
> > choice).
> 
> Are you are talking about a composite PK?
> 
> > One of the two keys can be changed by this form, so it
> > causes problems.
> 
> It is usually a bad idea to use domain data as PK. Having modifiable
> PKs is [generally] one of the worst ideas.
> 
> Michael.
> 
> -
> 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]



Re: [OT] Create/Edit Form

2005-07-27 Thread Michael Jouravlev
On 7/27/05, Andrew Tomaka <[EMAIL PROTECTED]> wrote:
> I realized the
> problem was actually a bit more complex than I was making it.  The
> database table I am editing requires two primary keys to make an entry
> unique (I'm a firm believer in a single PRImary key, but it wasn't my
> choice).  

Are you are talking about a composite PK?

> One of the two keys can be changed by this form, so it
> causes problems.

It is usually a bad idea to use domain data as PK. Having modifiable
PKs is [generally] one of the worst ideas.

Michael.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT] Create/Edit Form

2005-07-27 Thread Andrew Tomaka
I really like your Javascript solution, Kevin. However, I realized the
problem was actually a bit more complex than I was making it.  The
database table I am editing requires two primary keys to make an entry
unique (I'm a firm believer in a single PRImary key, but it wasn't my
choice).  One of the two keys can be changed by this form, so it
causes problems. I came up with a few solutions, but in the end, we
decided it would be easist (quick but dirty) to go ahead and just
delete all rows associated with the document and then reinsert them.
This way, we are sure to get the exact information that we want from
the users.

Thanks a lot for the quick responses guys.  I'll definitely keep the
JS flag tucked away in the back of my mind.

~ Andrew Tomaka

On 7/27/05, Andrew Tomaka <[EMAIL PROTECTED]> wrote:
> Hey all,
> 
> The following is pretty hard to understand.  I'm no good at describing
> my problems and wasn't sure how to explain it.  Hopefully, someone
> will get what I'm attempting to say
> 
> I'm working on a screen that allows a user to dynamically add rows via
> Javascript. I then have have a form that contains a list of beans that
> stores the data (but that's really beside the point).
> 
> My issue comes with the storage of this information.  The form can
> either be a blank form or it can be preloaded with other information
> depending on whether the record exists or not.  If it is preloaded,
> the user can edit the existing rows or add new rows.  The problem
> comes when I need to update the database.  When the user hits the save
> button, it submits all the information, but I have no way of telling
> if a specific row was edited or created. Because of this, I don't know
> whether to make an UPDATE query or an INSERT query.  Can anyone think
> of a creative way to do this without adding an extra query for each
> row?
> 
> Any insight would be greatly appreciated!
> 
> Thanks,
> ~ Andrew Tomaka
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT] Create/Edit Form

2005-07-27 Thread Ed Griebel
Andrew-

At some point, you're probably going to need to know which records
have been changed and which ones haven't. If the dataset isn't too
big, you could add a collection (java.util.List, etc.) of records that
you are displaying, and store it either as a formbean attribute or in
the session. If these records and/or lists are big, you will run into
problems with either method, but then is a user really going to want
to be able to edit hundreds of records anyway?

-ed

On 7/27/05, Simons Kevin <[EMAIL PROTECTED]> wrote:
> Just a suggestion,
> 
> If you do the rows by javascript you can add a hidden field which can have a
> value (eg 0 for update 1 for creation)
> 
> Regards,
> Kevin
> - Original Message -
> From: "Andrew Tomaka" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" 
> Sent: Wednesday, July 27, 2005 9:47 PM
> Subject: [OT] Create/Edit Form
> 
> 
> > Hey all,
> >
> > The following is pretty hard to understand.  I'm no good at describing
> > my problems and wasn't sure how to explain it.  Hopefully, someone
> > will get what I'm attempting to say
> >
> > I'm working on a screen that allows a user to dynamically add rows via
> > Javascript. I then have have a form that contains a list of beans that
> > stores the data (but that's really beside the point).
> >
> > My issue comes with the storage of this information.  The form can
> > either be a blank form or it can be preloaded with other information
> > depending on whether the record exists or not.  If it is preloaded,
> > the user can edit the existing rows or add new rows.  The problem
> > comes when I need to update the database.  When the user hits the save
> > button, it submits all the information, but I have no way of telling
> > if a specific row was edited or created. Because of this, I don't know
> > whether to make an UPDATE query or an INSERT query.  Can anyone think
> > of a creative way to do this without adding an extra query for each
> > row?
> >
> > Any insight would be greatly appreciated!
> >
> > Thanks,
> > ~ Andrew Tomaka
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >
> >
> > --
> > No virus found in this incoming message.
> > Checked by AVG Anti-Virus.
> > Version: 7.0.338 / Virus Database: 267.9.5/58 - Release Date: 25/07/2005
> >
> >
> 
> 
> 
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.338 / Virus Database: 267.9.5/58 - Release Date: 25/07/2005
> 
> 
> -
> 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]



Re: [OT] Create/Edit Form

2005-07-27 Thread Simons Kevin

Just a suggestion,

If you do the rows by javascript you can add a hidden field which can have a 
value (eg 0 for update 1 for creation)


Regards,
Kevin
- Original Message - 
From: "Andrew Tomaka" <[EMAIL PROTECTED]>

To: "Struts Users Mailing List" 
Sent: Wednesday, July 27, 2005 9:47 PM
Subject: [OT] Create/Edit Form



Hey all,

The following is pretty hard to understand.  I'm no good at describing
my problems and wasn't sure how to explain it.  Hopefully, someone
will get what I'm attempting to say

I'm working on a screen that allows a user to dynamically add rows via
Javascript. I then have have a form that contains a list of beans that
stores the data (but that's really beside the point).

My issue comes with the storage of this information.  The form can
either be a blank form or it can be preloaded with other information
depending on whether the record exists or not.  If it is preloaded,
the user can edit the existing rows or add new rows.  The problem
comes when I need to update the database.  When the user hits the save
button, it submits all the information, but I have no way of telling
if a specific row was edited or created. Because of this, I don't know
whether to make an UPDATE query or an INSERT query.  Can anyone think
of a creative way to do this without adding an extra query for each
row?

Any insight would be greatly appreciated!

Thanks,
~ Andrew Tomaka

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.5/58 - Release Date: 25/07/2005






--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.5/58 - Release Date: 25/07/2005


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[OT] Create/Edit Form

2005-07-27 Thread Andrew Tomaka
Hey all,

The following is pretty hard to understand.  I'm no good at describing
my problems and wasn't sure how to explain it.  Hopefully, someone
will get what I'm attempting to say

I'm working on a screen that allows a user to dynamically add rows via
Javascript. I then have have a form that contains a list of beans that
stores the data (but that's really beside the point).

My issue comes with the storage of this information.  The form can
either be a blank form or it can be preloaded with other information
depending on whether the record exists or not.  If it is preloaded,
the user can edit the existing rows or add new rows.  The problem
comes when I need to update the database.  When the user hits the save
button, it submits all the information, but I have no way of telling
if a specific row was edited or created. Because of this, I don't know
whether to make an UPDATE query or an INSERT query.  Can anyone think
of a creative way to do this without adding an extra query for each
row?

Any insight would be greatly appreciated!

Thanks,
~ Andrew Tomaka

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]