• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Action without redirect

 
Aleksander Braula
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem with making a struts2 action.

I have one action (under a button) that can be invoked from several different places on the site. When the users presses the button I want the action to be invoked but without changing the page and only reloading (with the same get parameters) it to see the new values.

Because the button is in number of different location I cant really determine where the call came from.

Is it possible to do it without multiple entries in the action mapping file ?

At the moment I'm redirecting to a conformation page and there I have a back button with a js "history.back()".
It works but it doesn't reload the page. Just gives the page from cache.



 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
Tom Rispoli
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a thought, could you hide an IFRAME on your page (put it in a hidden div) and then when your button is hit, set the src attribute of your IFRAME to the URL for your action. I think this will cause the IFAME to send the action to your server without affecting anything visible on the page. If you need you should be able to access the results of the action from your main page once the responce is returned to the IFRAME. You could probably make a custom tag for your button that will set up the DIV and IFRAME.

Also, I think you can do this kind of thing with ajax, but I've never used it so I'll defer to any one with ajax experience who has a slicker way to do this.

Hope this helps.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand the usecase. Can't you tie the button to a JavaScript function that sets a request value? Seems much easier than any IFRAME shenanigans.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic