Solved

AJAX and

Posted on 2006-07-18
1
905 Views
Last Modified: 2009-07-29
Hello AJAX Expert,

I am trying to implement the Select/Dropdown AJAX tag from the following link.  The Select/Dropdown tag work the following way: when selection within a dropdown field, a second select field will be populated.

See the following link: http://ajaxtags.no-ip.info/

The demo has 2 files associated with it, a JSP and a JAVA servlet.  The servlet name is DropdownServlet.  How is this servlet called from the JSP with the following ajax:select tag?

<ajax:select
  baseUrl="${contextPath}/dropdown.view"
  source="make"
  target="model"
  parameters="make={make}"
  preFunction="initProgress"
  postFunction="resetProgress"
  errorFunction="reportError"
  parser="new ResponseXmlParser()" />

I am using Netbeans IDE with JSP named dropdown and servlet named DropdownServlet.   I think DropdownServlet is supposed to return model given make to the JSP to be displayed in the chained dropdown box.

Heres a code snippet from the demo JSP:

<form action="." class="basicForm">
  <fieldset>
    <legend>Choose Your Car</legend>
    <label for="make">Make:</label>
    <select id="make">
      <option value="">Select make</option>
      <option value="Ford">Ford</option>
      <option value="Honda">Honda</option>
      <option value="Mazda">Mazda</option>
    </select>
    <span id="progressMsg" style="display:none;"><img alt="Indicator" src="./styles/indicator.gif" /> Loading...</span>

    <label for="model">Model:</label>
    <select id="model" disabled="disabled">
      <option value="">Select model</option>
    </select>
  </fieldset>
</form>
<div id="errorMsg" style="display:none;border:1px solid #e00;background-color:#fee;padding:2px;margin-top:8px;width:300px;font:normal 12px Arial;color:#900"></div>

<script type="text/javascript">
 /*
  * USER DEFINED FUNCTIONS
  */

function initProgress() {
  Element.show('progressMsg');
}

function resetProgress() {
  // show marker emblem
  var index = $('make').selectedIndex;
  var automaker = $('make').options[index].text;
  var imgTag = $('makerEmblem');
  if (index > 0) {
    imgTag.src = "./styles/" + automaker.toLowerCase() + "_logo.gif";
  }

  Effect.Fade('progressMsg');
}

function reportError() {
  if ($('model').options.length == 0) {
    $('errorMsg').innerHTML = "Dropdown busted!";
  }
  Element.show('errorMsg');
  setTimeout("Effect.DropOut('errorMsg')", 2500);
}
</script>

<ajax:select
  baseUrl="${pageContext.request.contextPath}/DropdownServlet"
  source="make"
  target="model"
  parameters="make={make}"
  preFunction="initProgress"
  postFunction="resetProgress"
  errorFunction="reportError"
  parser="new ResponseXmlParser()" />

Can you tell be how the servlet gets called in this AJAX demo?

Getting desperate.  Appreciate the help!!
0
Comment
Question by:i808237
1 Comment
 
LVL 3

Accepted Solution

by:
anumalas earned 500 total points
ID: 17182642
Hi

by default ajax:select will call cjajax.js java script. all the servlet communication functionality is written in that java script to communicate with the java sources like servlet or action classes

i suggest you to go thru that java script file

please refer the link, download cjajax.js and go thru

http://www.servletsuite.com/servlets/ajaxseltag.htm

Hope this will solve your confusion :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
library class in java 1 90
Struts tiles for layout structure along with Angular JS. 4 152
java operators 3 110
print map entry 34 55
Scenario: Your operations manager has discovered an anomaly in your security system. The business will start to suffer within 15 minutes if it is a major IT incident. What should she do? We have 6 recommendations for managing major incidents (https:…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now