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

How to call Struts 1 action without page reloading?

 
Konstantin Netkachev
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I only need to save form data in DB without page reloading or forwarding to other page.
Is there possibility to do that without AJAX usage?


So I want that PlanManagerAction only save data and doesn't do any forwarding/page reloading. Is it possible in Struts 1?
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Konstantin Netkachev wrote:
Is there possibility to do that without AJAX usage?


Add a hidden iframe to the page and set it as your form's target (html:form ... target="name_of_iframe")
 
Konstantin Netkachev
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I do this, after submiting page is opened in new browser window.

What's wrong?
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oops, double post, sorry!
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Konstantin Netkachev
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, thanks.
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome!
 
Richard Golebiowski
Ranch Hand
Posts: 213
Eclipse IDE Java Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also just set the status of the HttpServletResponse in the action to 204 by using setStatus:

response.setStatus(204);
 
Peter DeGregorio
Greenhorn
Posts: 10
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

response.setStatus(204);


response.setStatus(response.SC_NO_CONTENT);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic