JavaScript
  Home arrow JavaScript arrow Page 2 - JSP Libraries and AJAX
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

JSP Libraries and AJAX
By: Mamun Zaman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 13
    2007-08-29

    Table of Contents:
  • JSP Libraries and AJAX
  • AjaxTags Tags
  • jMaki
  • jMaki widgets
  • jMaki Menu, Data Table and More

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    JSP Libraries and AJAX - AjaxTags Tags


    (Page 2 of 5 )

    Let's start using AjaxTags tags.

    Remember, in the first part of this two-part tutorial series, I used plain JavaScript code to request a server side code for getting server time. Here is a similar example, but I use the ajax:anchors tag instead of JavaScript. Here is an example:

    <ajax:anchors target="res">
     
    Server Date Time: <a rel="nofollow" target="_blank" href = "date.jsp" class="contentLink">Click Here</a>
    </ajax:anchors>

    <div id="res">Server Date Time will replace this text.</div>

    The Anchors tag converts a normal <a> tag. It replaces the href attribute with an onClick event. So, if you click this link AjaxTags will request the date.jsp and the output will be placed in the <div> tag 'output'. Here is the date.jsp

    <b><%= new java.util.Date() %></b>

    Here is a tabbed page using ajax:tab and ajax:tabPanel tags.

    <ajax:tabPanel
        panelStyleId="tabPanel"
        contentStyleId="tabContent"
        currentStyleId="ajaxCurrentTab">
      <ajax:tab caption="Tab1"
        baseUrl="server.view?id=1"
        defaultTab="true"/>
      <ajax:tab caption="Tab2"
        baseUrl="srever.view"
        parameters="id=2"/>
      <ajax:tab caption="Tab3"
        baseUrl="server.view"
        parameters="id=3"/>
    </ajax:tabPanel>

    We can include parameters in baseUrl like HTTP GET (baseUrl= "server.view?id=1"), or we can use the parameters' attribute (parameters="id=3"). Here we created a tab panel of 3 tabs, and made tab1 default.

    Using AjaxTags' ajax:updateField tag, you can update the value of different text fields as shown in the example below. 

    We want to convert from centimeter to inch. We have a servlet called converter.view that takes a centimeter value and converts it into the equivalent in inches. We add two input elements, one for each of these. You need to have id attributes for these input elements for referencing. You also need a button to initiate the Ajax request. These elements need to be within a <form> tag. The important thing is the ajax:updateField needs to be placed after this form tag because it needs to refer elements using their ids.

    The attribute source specifies the source element. The attribute target specifies the element that will be updated with the server side response. To initiate the Ajax request, we need a button to be clicked. The attribute action references this button. Our servlet requires a parameter, namely centimeter. Here in the above example, we are sending the value of the element with id=c as the value of the parameter Centimeter. Please remember the braces {}.

    <form>
      <fieldset>

        <legend>Conversion</legend>

        <label for="c">Centimeter</label>
        <input type="text" id="c" />

        <input id="action" type="button" value="Convert"/>

        <label for="i">Inch</label>
       
    <input type="text" id="i" />
      </fieldset>
    </form>

    <ajax:updateField
      baseUrl="temperature_conversion.view"
      source="c"
      target="i"
      action="action"
      parameters="Celsius={c}"
    />

    AjaxTags has some other cool tags like autocomplete, callout, and portlet. We may discuss those tags at another time; meanwhile you can visit the AjaxTags project home page at http://ajaxtags.sourceforge.net/index.html.

    More JavaScript Articles
    More By Mamun Zaman


     

    JAVASCRIPT ARTICLES

    - Comparing Fields and Customizing Error Messa...
    - Checking Numbers and File Extensions with jQ...
    - Validating Digits and Dates with jQuery`s Va...
    - Validating Ranges, Emails, and URLs with jQu...
    - More Uses for the jQuery Tooltip Plug-in`s b...
    - Building Image-Based Tooltips with the jQuer...
    - Using the jQuery Tooltip Plug-in`s bodyHandl...
    - Using Rangelength, Min and Max with the Vali...
    - Using Minlength and Maxlength with the Valid...
    - Modifying Tooltip Coordinates with the jQuer...
    - Applying a Fade Out Effect with the jQuery T...
    - Tracking Mouse Movements with the jQuery Too...
    - Checking Online Forms with the Validator jQu...
    - Nested JavaScript Functions as Objects
    - The jQuery Tooltip Plug-in







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek