• Post Reply Bookmark Topic Watch Topic
  • New Topic

Refreshing JSP using AJAX

 
Taranjeet Bagga
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am developing a web page using JSF 1.1. There is a main JSP, and a JSP included in it using c:import. On main JSP, there is a data table. On selection of a row in the data table, I want to refresh a section within included JSP using AJAX. Please advise how I can do that. I am familiar with basic concepts of AJAX, and know how to return a value from servlet back to JSP, but not sure how to refresh only a portion of the page.
 
Pepe Tinto
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using jQuery your code could look like this:

Take a look at jquery api.
 
Tim Holloway
Bartender
Posts: 18415
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. JSF version 1 is very obsolete at this point. You should be using JSF version 2.

2. JSF version 2 doesn't work with "JSP"s any longer. It works with View Templates (.xhtml files). You do not use tag libraries or JSP directives to define them. View Templates are XML and work in conjunction with XML schemas (and not XML DTDs).

3. JSP JSTL and JSF do not work well together. Actually they worked even worse in JSF version 1 than they do in JSF version 2, but regardless, JSF has its own native functionality that in almost all cases does what JSTL does and does it in a more JSF-friendly way.

4. JSF version 2 has built-in AJAX support. JSF version 1 did not. Another reason why you should not be using JSF version 1.1 or 1.2.

Having said all that, I'll note that the JSF dataTable is defined in terms of its columns, not columns and rows, so there's no XML (VDL) element you can attach an AJAX re-render operation to. So when you change data in a dataTable's backing Model object, the entire table must be re-rendered. There may be some third-party extensions that can re-render individual rows, but it's not possible to do so using the core dataTable that comes with JSF itself.
 
Taranjeet Bagga
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim - My application runs on Websphere 6, and I think JSF 2 is not supported by it.

Pepe - Thanks for the advise. On the click on a row in the data table, I first need to execute some Java code (in servlet), and then refresh the portion of included JSP. Please advise how this can be done.
 
Tim Holloway
Bartender
Posts: 18415
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WAS version 6 is also horribly obsolete. IBM stopped supporting it 30 Sept 2013. Any changes to hardware, OS, sunspot activity or any other thing that might cause WAS 6 to fail and the only support IBM is going to give to make it function again is going to have to be specially negotiated and undoubtedly very expensive. Despite what a lot of people think, software does indeed rot. Generally from the outside in as the various environmental assumptions it was written under are replaced by newer environments.

WAS 7 left general availability 17 Oct 2008 and WAS 8 left general availability 22 July 2011, with 8.5 leaving general availability in 2012.

However, it is definitely possible to code for Facelets in WAS 6 because I did it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!