• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Update Database with the newly entered value

 
Greenhorn
Posts: 5
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But the orderId tells the database which row to update.
 
judes jk
Greenhorn
Posts: 5
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Solved the problem...
Actually the key name and the property name were different. hence the new value was not getting populated.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic