Re: [5.3.6] Listening to native tapestry ajax events

2012-12-16 Thread Geoff Callender
Sorry, I shouldn't have suggested subclassing. The preferred way to extend 
and/or override a Tapestry component's functionality is to "wrap" it. If you 
can't achieve what you want with wrapping then maybe create your own component 
by copying DateField? It might not be much work.

As for your last question, I'll repeat it: "A question to the developers, why 
isn't tapestry's components events
bubbled by default ? Performance issues ?".

On 17/12/2012, at 3:13 AM, Muhammad Gelbana wrote:

> I should try extedning the datefield component but I have a question, is it
> just about my component class "extending" tapestry's component class and
> that's it ? No other wiring needed ?
> 
> Just a plain java "extends" and referring to my component instead ?
> 
> A question to the developers, why isn't tapestry's components events
> bubbled by default ? Performance issues ?
> 
> On Sun, Dec 16, 2012 at 5:42 AM, Geoff Callender 
> wrote:
> 
>>> This may help:
>>> 
>>>  http://localhost:8080/jumpstart/examples/component/eventbubbling
>> 
>> Wrong. I meant this:
>> 
>> 
>> http://jumpstart.doublenegative.com.au/jumpstart/examples/component/eventbubbling
>> 
>> 


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: [5.3.6] Listening to native tapestry ajax events

2012-12-16 Thread Muhammad Gelbana
I should try extedning the datefield component but I have a question, is it
just about my component class "extending" tapestry's component class and
that's it ? No other wiring needed ?

Just a plain java "extends" and referring to my component instead ?

A question to the developers, why isn't tapestry's components events
bubbled by default ? Performance issues ?

On Sun, Dec 16, 2012 at 5:42 AM, Geoff Callender wrote:

> > This may help:
> >
> >   http://localhost:8080/jumpstart/examples/component/eventbubbling
>
> Wrong. I meant this:
>
>
> http://jumpstart.doublenegative.com.au/jumpstart/examples/component/eventbubbling
>
>


Re: [5.3.6] Listening to native tapestry ajax events

2012-12-15 Thread Geoff Callender
> This may help:
> 
>   http://localhost:8080/jumpstart/examples/component/eventbubbling

Wrong. I meant this:


http://jumpstart.doublenegative.com.au/jumpstart/examples/component/eventbubbling



Re: [5.3.6] Listening to native tapestry ajax events

2012-12-15 Thread Geoff Callender

On 16/12/2012, at 10:14 AM, Muhammad Gelbana wrote:

> Some tapestry components do fire ajax events and reach out to the server
> and it get's handy sometimes to listen to those events. For instance the
> datefield event fired to format the selected date. Side question, why does
> the date field have to reach out to the server to format the selected date,
> can't it be done on the client side ?

From the source code of the DateField component, here is the "Format" event 
handler:

/**
 * Ajax event handler, used after the client-side popup completes. The 
client sends the date, formatted as
 * milliseconds since the epoch, to the server, which reformats it 
according to the server side format and returns
 * the result.
 */
JSONObject onFormat(@RequestParameter(INPUT_PARAMETER)
String input)
{
JSONObject response = new JSONObject();

try
{
long millis = Long.parseLong(input);

Date date = new Date(millis);

response.put(RESULT, format.format(date));
} catch (NumberFormatException ex)
{
response.put(ERROR, ex.getMessage());
}

return response;
}

> 
> Any way the main question is, I saw this url being posted using ajax:
> 
>> http://localhost/tests/results.starttime:format?input=135123230
> 
> 
> So I tried listening to the "format" event fired from the "starttime"
> component but I got nothing. I thought may be it's the missing context so i
> added a "long" parameter to the even method, but it didn't work either.
> 
> So how I can I, on the server side, listen to the datefield component fired
> ajax events ? And how can this be done in general since some urls indicate
> events that aren't actually the events being listened to on the server !

You can't.  As you can see in the source above, DateField handles "Format" 
without bubbling up an event to the container. If you need bubbling up, then 
try creating your your component by subclassing DateField and overriding the 
above method.

> Like the zone refreshing mixin. It fires a "zonerefresh" event while I
> could listen to it only through the "refresh" event.

From the source code of the "ZoneRefresh" component, here is the "ZoneRefresh" 
event handler:

   Object onZoneRefresh()
   {
  CaptureResultCallback callback = new 
CaptureResultCallback();
  resources.triggerEvent(EventConstants.REFRESH, context, callback);
  
  if(callback.getResult() != null){
 return callback.getResult();
  }
  
  return zone.getBody();
   }

As you can see, it bubbles up the REFRESH event.

This may help:

http://localhost:8080/jumpstart/examples/component/eventbubbling

> 
> Thank you.

Cheers,
Geoff