Jakarta > Tapestry
Jakarta
 

XTile

A component providing the required JavaScript to pass some information to the server and receive its response without reloading the page (Ajax)

Parameters

Name Type Direction Required Default Description
listener IActionListener in yes The listener that will be invoked when the Javascript function with the given name is invoked. Any parameters passed to the send function will be available from cycle.getServiceParameters(). In addition, the listener can perform cycle.setServiceParameters() to pass an array of strings to the JavaScript receive function.
sendName String in yes The name of the JavaScript function that the script will define to allow the application to send information to the server.
receiveName String in yes The name of the JavaScript function that the script will call to allow the application to receive information from the server some time after the send function has been invoked.
errorName String in no null The name of the JavaScript function that the script will call to indicate that an error has occurred while sending the information to the server.
disableCaching boolean in no false Some browsers cache repeated requests that have identical URLs. Pass 'true' to this parameter to disable caching by making the URLs unique.

Body: removed

Informal parameters: allowed

Reserved parameters: none

Examples

The XTile example has portions implemented in the HTML and a listener method in the page class. They are broken down as follows:

XTileExample.html

<html>
  <head>
    <title>XTile Example</title>
  </head>
  <body>
    <span jwcid="@contrib:XTile" listener="ognl:listeners.handleListRequest"
        sendName="sendPrefix" receiveName="receivevList"/>
    <form action="Results.html" method="post">
       <input type="text" onkeyup="sendPrefix(this.value)"/>
       <br/>
       <textarea name="listing" rows="5"></textarea>
    </form>
    <script>
      function recvList(arr) {
      	document.f.listing.value = arr.join("\n");
      }
    </script>

  </body>
</html>
	

Then in your page class you just need to add the appropriate method.

XTileExample.java

    .
    .
    .
    public void handleListRequest(IRequestCycle cycle) {
      Object[] params = cycle.getServiceParameters();
      if (params.length == 0) return;

      String typed = params[0].toString();
      String[] ret = findCompletions(typed);
      cycle.setServiceParameters(ret);
    }
    .
    .
    .