Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Ajaxifying web application

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 67618
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear.

But, just tell me why do you mentioned "Vectors are old" ?
 
Bear Bibeault
Sheriff
Posts: 67618
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
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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic