• 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

JSP + Spring + Ajax

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a similar problem to this one and a solution to this one might help him as well.

Basically I have a web page which contains a table containing some data. The table is created when the page is loaded from the controller model. This works fine.
This table is defined on a separate jsp and uses JSTL to display each line of data.

In the meantime some changes can happen on the database side. Instead of reloading the entire webpage I would like to reload the table by "refreshing" its model when the user clicks on the refresh button.

1. Is Ajax/JavaScript/jQuery the proper way to do this?

2. If I get it right, this [document.getElementById("dataTable").innerHTML = <jsp:include page="auditTrailTable.jsp"/>] doesn't work because it will be included the first time the page is loaded. Correct?

3. A way to do it would be to replace content of the dataTable div with a new table generated on the server side and sent back to the browser?

4. I like to keep things separated (model, view, controller, jsp divided) and no code duplication.
So if I use Ajax, is there a way to keep this separation to generate the table a) the first time the page is loaded b) when the user clicks on refresh?

5. How to do it properly?

Here is my current code:

auditTrail.jsp


auditTrailTable.jsp


AuditTrailController.java
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
any one found solution to this?

I am also facing similar problem where div element is loaded dynamically by JSTL (c:forEach). and when I want to reload this div, all the suggested solutions on net asks to update innerHTML via something similar to

document.getElementById(divID).innerHTML = "new string";
 
Sheriff
Posts: 67748
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that's a viable approach.

It's made easier by the use of a library such as jQuery.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic