How to Use Ajax With Tapestry

Tapestry is an Apache program that makes it easy to create pages in Java, and that works alongside AJAX, a form of Javascript, to allow users to update partial sections of an already existing Web page. This partial update is accomplished by turning a DIV section of the page into a Tapestry "Zone," which can then be updated using AJAX scripts to add functionality without re-coding the entire page.

Instructions

    • 1

      Open the file of the Web page that you want to edit by right-clicking on it and choosing "Open With," then "Notepad."

    • 2

      Scroll down the page and locate the "DIV" section to which you want to add AJAX scripts.

    • 3

      Type the following code after the first "DIV" tag:

      <t:zone t:id="ZoneName" id="zonename"> Content </t:zone>
      <t:actionlink t:id="highlight" zone="zonename">Content</t:actionlink>

      Insert whatever content you would like where the word "Content" is in the above code. For example, you can type "Update: This is an update" in order to insert a text update into your website.

    • 4

      Create your AJAX script that corresponds to the Tapestry Zone you created after the DIV tag and place it between the "<HEAD" and "</HEAD>" tags. You can use whatever AJAX script you'd like to perform the action you need. For example, an AJAX script that works with the zone to list the results for the zone's name might look like the following code:

      <HEAD>
      List<String> ZoneName(String partial)
      {
      List<Account> matches = account.findZoneName(partial);
      List<String> result = true.ArrayList<String>
      for (Account X : results)
      {
      result.add(a.getName());
      }
      return result;
      }
      </HEAD>

Related Searches:

Resources

Comments

Related Ads

Featured