Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reloading Page completely after submit

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After I submit one of my forms, if all went well, I just go back to the form again. But the form is not being reset. What do I need to do in order for everything to go back to the beginning?
Thanks.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me clarify. I can reset the form so that all values are "" again. The problem is that my custom javascript blows up after the form is submitted once. So the first submit everything works fine, but when I try and submit again, and I call onsubmit="getAuthors()" it blows up. So I am thinking I need the page to completely reload all together, like I am there for the first time.
Thanks.
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that the ActionForm's reset method will do this, but the API documentation recommends resetting to default values for "update" types of pages in the Action.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Matthew Phillips:
I believe that the ActionForm's reset method will do this, but the API documentation recommends resetting to default values for "update" types of pages in the Action.

Well, I don't really have an ActionForm. I am using DynaValidatorForm. And in my Action class I am casing the form from the execute() into a DynaValidatorForm object. This object does have a reset() method, but that is not solving my problem. My problem is not resetting the form values, but rather reloading the page.
Anytime the page basically does a PostBack or calls itself from the findForward() method, my javascript stops working. So if I have a validation error or after I submit a successful form, I come back to the same page, and that is when my javascript blows up on me.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I moved my javascript from an external js file into the JSP page and now it works just fine. Does anyone know why this would happen? Why would the page lose the reference to the external js script?
Thanks.
 
Paul Duer
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gregg,
Did you use any ../../ notation in your def for the .JS? Often the context path will change after a servlet is executed.
Also there some bugs with IE 5 and up that if you save and attachment and return to the same page, then Javascript won't execute, but I don't think that's happening to you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic