Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ajaxifying web application

 
Shantanu Puranik
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my application, I want to implement AJAX to populate drop down list for Employee Codes.

The selection of Employee Code depends on other form parameters already selected like location, Department, Section etc.

The method containing business logic for the same is already coded and returns a Vector.

Being a newbie in Ajax, what I know is it uses JavaScript.
But, the calling JSP needs java Object (Vector).

Is there any way out to achive this?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65228
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If by "calling JSP' you mean the JSP that rendered the page that contains the form, that's entirely irrelevant. The JSP executed and sent the entire HTML page to the browser and is now out of the picture.

What you need to do now is to trigger an Ajax call based upon what client-side triggers need to initiate the population of the dropdown. This should be a request that only returns the data necessary to fill in the drop-down as its response -- not the entire page again. This response can be in any format that is convenient: XML or JSON being the most obvious.

So whatever servlet gets invoked by the Ajax request, will call your method that gives the data Veector (Vector? You should be using a List -- Vector is old) and converts the data into XML or JSON format for the page to use.

The Javascript that executes as a result of the completion of the Ajax request then uses this data to "fill in" the dropdown.
[ April 05, 2007: Message edited by: Bear Bibeault ]
 
Shantanu Puranik
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear.

But, just tell me why do you mentioned "Vectors are old" ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65228
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since Java 1.2, the Vector has been considered rather passe and other implementors of List (such as ArrayList) are preferred. Doesn't mean you can't use it -- it's just a bit odd to see it used these days.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic