• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

capture request parameters onunload

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm trying to create an "auto-save" function in my web-app. We have several tabs the user may navigate through. Rather than having to hit the save button each time, I want to call the save action for the page b/f loading the next page.

There are too many tabs to "hard code" so I'm looking for a generic solution.

What I need:

A javascript method that captures all of the request parameters (onunload) - then put them in a hashmap (or something). I plan on overriding the request processor class in struts.

psuedo code: (sorry - i'm a novice at javascript)
{
HashMap hm =new HashMap();//to store parms and values
allRequestParameters = ?// somehow get all request parameters? is there a method for this?
for(int i = 0; i<allRequestParameters.size();i++){
hm.put(allRequestParameters.getParameter(i), allRequestParameters.getValue(i));
}
}

Can you help?
[ April 26, 2005: Message edited by: chris gar ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are going to have arough time coding this ionounload since many events fire the event. Plus you are mnot going to be able to transfer the data from the client side to the server side without a form submission of some sort. You have to hope that when the page exits your code executes.

Eric
 
chris gar
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply, Eric.

I don't have to put it in onunload. That was a suggestion someone made to me. Do you have any other suggestions on where I could/should put it?

And do you know how to somehow "load" the request parameters?
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

allRequestParameters = ?// somehow get all request parameters? is there a method for this?



you can use request.getParameterValues() which returns a string array of all the request parameters if that is what you are looking for.
and if you have save buttons in ur page then you must be calling some function in the on click of th button.
call this function when you leave the tab by some of the javascript methods
not sure which one.
on unload will work if you are calling a jsp on the tab click.
look arround and you will find one suitable for u.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can not request the parameters unless you post back the data. Closing the browser, you risk the fact that it will not post back the data.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic