|
|
Hi Howard,
I think that using a function that returns an array of strings or something
else would be ideal. It was my oginal idea too.
I chose the current approach for two reasons:
- there may be many such scripts needed in a given page/component. This
makes the possibility of a single entry point that would result from
inheritance a bit problematic.
- even so, it was possible to cobble something up with OGNL and Java inner
classes to provide interfaces with such function, but I think that approach
makes things more complex than many people would like to swallow.
I feel that the 'listeners' in 3.0 are good enough for that goal as they
allows quick results without much headache. Since my target was a component
for vanilla Tapestry 3.0, anything else was suboptimal.
In Tapestry 3.1 the story is different, however. We can do things right in
there.
----- Original Message -----
From: "Howard Lewis Ship" <hlship@xxxxxxxxx>
To: "Tapestry users" <tapestry-user@xxxxxxxxxxxxxxxxxx>
Sent: Friday, March 25, 2005 6:49 PM
Subject: Re: XTile: integrating XMLHttpRequest (aka Ajax) with Tapestry
> Interesting approach, using the service parameters as a way to
> communicate back to the client.
>
> My thoughts on this were more structured; the page/component would
> implement an interface (somewhat like IExternalPage) and the method
> invoked would return a simple string. I expect a whole famility of
> different services that expect the result to be strings, or XML/HTML,
> or whatever else.
>
> Anyway, people are clammoring for this stuff; I wish I had the spare
> cycles to deal with this immediately. Great job as usual!
>
>
> On Fri, 25 Mar 2005 18:41:44 +0200, Mind Bridge <mindbridgeweb@xxxxxxxxx>
wrote:
> > Hi all,
> >
> > I have put the XTile component on T-Deli (www.t-deli.com).
> >
> > This component allows a simple JavaScript function call to invoke a
listener
> > on the server and pass data to it using the now popular XMLHttpRequest
> > mechanism. The listener can also return data, and another Javascript
> > function will be invoked when it is received.
> >
> > In short, this makes using XMLHttpRequest as simple as using a
DirectLink.
> >
> > Here is a quick example of this functionality:
> > http://www.t-deli.com/ex1/app?service=page/XTileTest
> >
> > Basically, it is a name completion along the lines of Google Suggest.
When
> > you start typing the name of a country, the web page will ask the server
for
> > possible completions. The completions will be then displayed underneath.
> >
> > Implementing this functionality is simple. First declare the XTile
component
> > in your page:
> >
> > <span jwcid="@xtile:XTile" listener="ognl:listeners.handleCallback"
> > sendName="sendValue" receiveName="recvCompletions"/>
> >
> > The above means that when the JavaScript function sendValue() is called,
the
> > handleCallback listener will be invoked, and that when it finishes, the
> > recvCompletions() function on the client must be called.
> >
> > The text field is then modified to call sendValue() when a modification
> > occurs:
> >
> > <input onkeyup="sendValue(this.value)" .../>
> >
> > The handleCallback() listener is implemented in the Java code to
generate
> > the completions:
> >
> > public void handleCallback(IRequestCycle cycle)
> > {
> > Object[] params = cycle.getServiceParameters();
> > if (params.length == 0) return;
> >
> > String typed = params[0].toString();
> > String[] ret = findCompletions(typed);
> > cycle.setServiceParameters(ret);
> > }
> >
> > Finally, back in the HTML define the function recvCompletions() to
handle
> > the returned completions:
> >
> > function recvCompletions(arr) {
> > document.f.comps.value = arr.join("\n");
> > }
> >
> > That's all. The component produces the other necessary Javascript and
> > registers the needed Tapestry service to handle the rest.
> >
> > Note that while this code has been in circulation for a while, it has
been
> > repackaged and refurbished, so it might cause some problems. It has not
been
> > tested with a very wide variety of browsers, although it does work with
> > Firefox and IE. Any help there is appreciated :)
> >
> > Finally, a lot of other dynamic components can be very easily produced
using
> > XTile, such as a proper completion text field (not just a quick demo),
a
> > spelling checker, etc. A lot of ideas were described in earlier messages
in
> > this list. If anyone wants work on that, please let me know -- I would
be
> > happy to lend a hand.
> >
> > Best regards,
> > -mb
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@xxxxxxxxxxxxxxxxxx
> > For additional commands, e-mail: tapestry-user-help@xxxxxxxxxxxxxxxxxx
> >
> >
>
>
> --
> Howard M. Lewis Ship
> Independent J2EE / Open-Source Java Consultant
> Creator, Jakarta Tapestry
> Creator, Jakarta HiveMind
>
> Professional Tapestry training, mentoring, support
> and project work. http://howardlewisship.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@xxxxxxxxxxxxxxxxxx
> For additional commands, e-mail: tapestry-user-help@xxxxxxxxxxxxxxxxxx
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: tapestry-user-help@xxxxxxxxxxxxxxxxxx
|
|