• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Avoiding form resubmission

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,I have a form where i have 2 textboxes,1 dropdown and a submit button. when i select an option from the dropdown, values for the other fields are fetched from DB and displayed in the form. i am doing this through javascript by submitting the form once the option from dropdown is selected. the user can change the values that are fetched from the DB and submit again using submit button. however by clicking the browsers bcak button user should not submit the form using submit button. ie user should not resubmit(by clicking on the submit button provided) the form by coming thrpugh the browsers back button. how to handle this.
 
sri kris
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can anyone suggest any idea??
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Method i suggest is to create a session variable and based on its value disable or enable the button.
 
Dishpal Bhaluja
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use struts logic tag to check whether variable present in the required scope
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two textboxes and 1 dropdown menu. When you select an option, the form is submitted and the results of a database query populate the values of the two textboxes.

There should be two forms here, not one. The first form handles the selecting of an option and the retrieval of data from the database. The second form handles the editing of data and saving of revised data.
 
Dishpal Bhaluja
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Clark why we need two forms here;Just one form and an ajax call for drop down will do the rest.Cant we?
 
sri kris
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why to have two fomrs?? cant we do it in a single form itself??
anyway can you please explain how it could be done using two forms as well?
 
Dishpal Bhaluja
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes,It can be solved in one form itself.

On drop down selection call your action class's function through javascript and pass on the parameter you got to that function.From there do your business logic and return the results back as an xml/json response and output the result back to your jsp page.

Simple solution:Use Ajax.

Refer Book:Struts complete Reference.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

why to have two fomrs?? cant we do it in a single form itself??



It is unclear why you even want to do it in a single form. There are two server actions going on here, not one. There are two database actions here, not one. So, why try to do it with one form?

You still need either two Actions or a single Action that handles different requests.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic