jQuery in Action, 2nd edition*
The moose likes Struts and the fly likes Update Database with the newly entered value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Update Database with the newly entered value" Watch "Update Database with the newly entered value" New topic
Author

Update Database with the newly entered value

judes jk
Greenhorn

Joined: Mar 09, 2011
Posts: 5

Hi,

In my struts application, am retrieving some values from the database for the user to edit. After editing, the newly entered value has to be submitted to the database.
The issue is, I am able to retrieve and display the value from the database, but the newly entered value is not getting updated, instead the old value is still getting submitted.

Can anybody tell me where am I going wrong....

Any help appreciated.

Thanks
Judes
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
You're going to need to post some code before anyone will be able to help you. Have you determined at what point the problem is occuring? Did the new value get sent from the client back to the server in the request? Did your form get updated with the new value? Does the value in the form change from when the action starts to when you perform your DB update?
judes jk
Greenhorn

Joined: Mar 09, 2011
Posts: 5

Hi Tom, This is my jsp, where am getting and displaying the values from the database.here is the place where i want to edit the value 'quantity'from the database with the new value


And am getting the value of quantity in My Action Class


Thanks Judes
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
In your jsp, it doesn't look like you are setting the orderId value in your hidden field so that value is not returned to your action class and, therefore, not correct in your update SQL. I think your println of the SQL statement would show that.
judes jk
Greenhorn

Joined: Mar 09, 2011
Posts: 5

Tom Reilly wrote:In your jsp, it doesn't look like you are setting the orderId value in your hidden field so that value is not returned to your action class and, therefore, not correct in your update SQL. I think your println of the SQL statement would show that.


But I dont have a problem with the orderId as I am not going to change it ...But my problem is with the quantity field as I need to update only the 'quantity' value with the new one everytime the user updates it .
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
But the orderId tells the database which row to update.
judes jk
Greenhorn

Joined: Mar 09, 2011
Posts: 5

Tom Reilly wrote:But the orderId tells the database which row to update.


This is my cart .jsp which displays the available cart items

This is my Update Cart.java

This is my update cart.jsp. This gets displayed when the user clicks on the order id

And this is my Modify cart.java

...I am getting everything fine. but during the final execution, ie after changing the value of 'quantity' in the update cart .jsp, the newly entered value s not getting updated ...I am new to struts.

Thanks Judes
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
I've never used the "key" attribute on a textfield before, so I'm not familiar with how it works so if I'm missing something here that may be why, and showing the html that it generates might help. That said, you are storing "quantity" in a hidden field and I don't see how it will get updated (do you have some javascript to move the value from the textfield to the hidden field?). Can you let us know how you think the hidden quantity field is getting updated?
judes jk
Greenhorn

Joined: Mar 09, 2011
Posts: 5

Solved the problem...
Actually the key name and the property name were different. hence the new value was not getting populated.

 
Consider Paul's rocket mass heater.
 
subject: Update Database with the newly entered value