aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Ajaxifying web application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Ajaxifying web application" Watch "Ajaxifying web application" New topic
Author

Ajaxifying web application

Shantanu Puranik
Ranch Hand

Joined: Jun 10, 2004
Posts: 67
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?


--- Shantanu
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61658
    
  67

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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Shantanu Puranik
Ranch Hand

Joined: Jun 10, 2004
Posts: 67
Thanks Bear.

But, just tell me why do you mentioned "Vectors are old" ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61658
    
  67

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ajaxifying web application