File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Reloading Page completely after submit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Reloading Page completely after submit" Watch "Reloading Page completely after submit" New topic
Author

Reloading Page completely after submit

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

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.


GenRocket - Experts at Building Test Data
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

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

Joined: Mar 09, 2001
Posts: 2676
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.


Matthew Phillips
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

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

Joined: Jul 11, 2001
Posts: 15300
    
    6

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

Joined: Oct 10, 2002
Posts: 98
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Reloading Page completely after submit