Hi,

The code seems okay on a first look, but here is one possible test. Change
    <script>
        function receiveCompletions(arr) {
        document.f.comps.value = arr.join("\n");
        }
    </script>

to sth like this

    <script>
        function receiveCompletions(arr) {
        alert(arr);
        }
    </script>

and see if you get any alerts with sth other than null. If you do then the
problem is with 'document.f.comps.value'. Otherwise receiveCompletions() is
not called at all. Is this specific to a particular browser?

----- Original Message ----- 
From: "Surya Prakash" <[EMAIL PROTECTED]>
To: "Tapestry users" <tapestry-user@jakarta.apache.org>
Sent: Wednesday, May 11, 2005 11:33 AM
Subject: RE: Using XTiles component


> Hi,
>
> Sorry for a bit vague.
>
> Configuration:  JDK1.5, Tomcat 5.0, Tapestry 3.0.3, IE 6+, Firefox 1+,
> Eclipse 3M7, Spindle, X-Tiles jar available from t-deli.com
>
> Trying to replicate the X-Tiles demo given at given at T-Deli.com on the
> local machine using above configuration.
>
> Problem:  I downloaded the source code given at the t-deli site to display
a
> list of countries onkeyup script using Ajax.  The source I am using is
given
> below:
> ***********************************
> Application file:
>
> <application name="AjaxTest">
>
> <library id="xtile"
> specification-path="/org/mb/tapestry/xtile/xtile.library"/>
>
> </application>
> ************************************
> Home Page
>
> <html jwcid="@Shell" title="XTile example">
> <body jwcid="@Body">
>
> Start typing the name of a country in the field below. <br>
> The page will connect to the server and ask for possible completions.
> <p>
>     <form name="f">
>     <table cellspacing="0" cellpadding="0">
>         <tr>
>             <td>Country: </td>
>             <td><input type="text" style="width: 200px"
> onkeyup="sendValue(this.value)"/></td>
>         </tr>
>         <tr>
>             <td></td>
>             <td><textarea name="comps" rows="10" style="width: 200px"
> ></textarea></td>
>         </tr>
>     </table>
>     </form>
>
>     <span jwcid="@xtile:XTile" listener="ognl:listeners.handleCallback"
>         sendName="sendValue" receiveName="receiveCompletions"/>
>
>     <script>
>         function receiveCompletions(arr) {
>         document.f.comps.value = arr.join("\n");
>         }
>     </script>
>
>     <span jwcid="@xtile:Timeout"/>
> </body>
> </html>
> ****************************************************************
>
> Home.java
>
> package examples;
>
> import java.util.ArrayList;
> import java.util.Collections;
> import java.util.Iterator;
> import java.util.LinkedHashSet;
> import java.util.List;
> import java.util.Locale;
> import java.util.Set;
>
> import org.apache.tapestry.IRequestCycle;
> import org.apache.tapestry.html.BasePage;
>
> public class Home extends BasePage
> {
> private final static int MAX_COMPLETIONS = 10;
>
> private static Set countries = new LinkedHashSet();
>
> static {
> System.out.println("Entered in static block");
> Locale[] locales = Locale.getAvailableLocales();
> for (int i = 0; i < locales.length; i++) {
> String country = locales[i].getDisplayCountry();
> if (country != null) {
> //System.out.println("Country:"+country);
> countries.add(country);
> }
> }
> }
>
> private String[] findCompletions(String typed)
> {
> System.out.println("Entered in findCompletions and
> typed:"+typed);
> if (typed.equals(""))
> return null;
>
> typed = typed.toLowerCase();
>
> List completions = new ArrayList();
> for (Iterator it = countries.iterator(); it.hasNext();) {
> String country = (String) it.next();
> //System.out.println("Country:"+country);
> if (country.toLowerCase().startsWith(typed)){
> System.out.println("Added
> country:"+country);
> completions.add(country);
> }
> if (completions.size() == MAX_COMPLETIONS)
> break;
> }
> Collections.sort(completions);
>
> return (String[]) completions.toArray(new
> String[completions.size()]);
> }
>
>
> public void handleCallback(IRequestCycle cycle)
> {
> System.out.println("Entered in handleCallback");
> Object[] params = cycle.getServiceParameters();
> if (params.length == 0) return;
>
> String typed = params[0].toString();
> String[] ret = findCompletions(typed);
> for(int i=0; i<ret.length; i++){
> System.out.println("return list:"+ret[i]);
> }
> cycle.setServiceParameters(ret);
> }
>
> }
> ******************************************************
>
> As shown in the source, the print statements are printing the list of
> countries in the handleCallback and the returned String[] array ret is
> correctly set to the service parameters, when I am typing a key but the
list
> is not shown in the text area in the html page.
>
>
> Thanks in advance.
>
> Surya
>
>
> -----Original Message-----
> From: Jamie [mailto:[EMAIL PROTECTED]
> Sent: 10 May 2005 18:17
> To: Tapestry users
> Subject: Re: Using XTiles component
>
> Can you be more specific? It's hard to answer such a general question.
>
> Surya Prakash wrote:
> > Hi,
> >
> >
> >
> > I just started working with Tapestry and in my current project need to
use
> > Tapestry with Ajax. I am trying to understand the working of XTiles
> > component and though I was able to send the request, not receiving any
> > response back. I am using the demo source given at t-deli.
> >
> >
> >
> > Any help will be greatly appreciated.
> >
> >
> >
> > Thanks in advance.
> >
> >
> >
> > Surya
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to