• 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

STRUTS and Ajax

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm using STRUTS 1.2 and the "javawebparts ajaxparts" taglib.
I'm trying to implement 'please wait' functionality in a JSP page.
I wrote a Action/JSP page that has two display modes.
The first display mode displays a 'please wait' graphic inside a DIV.
At the end of this page display mode, I manually kick off an Ajax request for the same Action/JSP with a special flag in a hidden form element that tells the JSP to display in a different mode.
This new content is displayed inside the DIV described.

Everything I described so far is working, but when I post back the form on the JSP page, I always get the same form values, even if I modify them with JavaScript on the client.

Example:

<html:hidden property="operation" value="update" />

When I check the parameter value on the server as follows:
request.getParameter("operation")

It always returns the string "update" even if I change the value on the client (browser) via Javascript.

Since the form elements in question are outside the DIV, this would not seem to be AJAX related, but I have not been able to solve this problem.
I'm wondering if there's something about the STRUTS framework that I'm missing.

Any help would be greatly appreciated.

Thanks!
Jonathan
 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It could be possible that your AJAX calls are getting cached by the browser. That is why you receive the same response from the server inspite of making changes at the client end.

I suggest that you add the following line to the server method which handles your AJAX call. Put this line before you flush the response.


That should fix your problem.
 
Ranch Hand
Posts: 341
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jonathan Brenner,
Welcome to JavaRanch.

Well, as suggested by Anirvan it sounds like a caching problem.
But adding only one line may not solve the problem as

response.setHeader("Cache-Control", "no-cache");

corresponds to HTTP 1.1 and may not work in certain scenarios and especially when your proxy server maybe caching data.

You should set the following:



Hope that helps.
 
jonathan brenner
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the prompt replies!

I figured out the issue, and it wasn't caching.
I had declared the hidden form element outside the conditional logic that determined which of the two display modes to render, so it was being rendered twice with the same name.
When I changed the hidden input to an input type=text, the problem immediately became apparent.
I wish there were a way to "view source" on an HTML page that displayed the current innerHTML content of a DIV; that would make it much easier to debug this sort of thing.


Thanks again!
Jonathan.
 
Anirvan Majumdar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh well,
you could always check out the view source chart plugin for Firefox which allows you to view the source of an HTML page even if the DOM is being dynamically altered.
 
What's brown and sticky? ... a stick. Or a tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic