Re: @BeginRender equivalent for component AJAX events

2013-04-24 Thread Lance Java
The ZoneRefresh mixin fires the refresh event passing the (optional)
context parameter.

So, add a handler to the containing page / component.

Eg: void onRefresh(Foo context) {...}

If you return a Block, this will be rendered (zone.getBody() renders by
default).


Re: @BeginRender equivalent for component AJAX events

2013-04-24 Thread Michael Prescott
Thanks, Lance, that looks like it will do the trick nicely.

Do you think that the 'refresh' event should be added to the ZoneRefresh
mixin's documentation?  Is this public/won't change, or a gory internal
detail?


On 24 April 2013 04:47, Lance Java lance.j...@googlemail.com wrote:

 The ZoneRefresh mixin fires the refresh event passing the (optional)
 context parameter.

 So, add a handler to the containing page / component.

 Eg: void onRefresh(Foo context) {...}

 If you return a Block, this will be rendered (zone.getBody() renders by
 default).



Re: @BeginRender equivalent for component AJAX events

2013-04-24 Thread Lance Java
Far from being a gory detail, it's part of the public API for the mixin,
very similar to AutoComplete's provideCompletions event.

The mixin should ideally declare the event using @Events(refresh) and
should have a mention in the javadoc too.


Re: @BeginRender equivalent for component AJAX events

2013-04-24 Thread Michael Prescott
Okay! I've filed it as https://issues.apache.org/jira/browse/TAP5-2111


On 24 April 2013 09:07, Lance Java lance.j...@googlemail.com wrote:

 Far from being a gory detail, it's part of the public API for the mixin,
 very similar to AutoComplete's provideCompletions event.

 The mixin should ideally declare the event using @Events(refresh) and
 should have a mention in the javadoc too.



Re: @BeginRender equivalent for component AJAX events

2013-04-24 Thread Ivan Khalopik
One note about ZoneRefresh mixin:

https://issues.apache.org/jira/browse/TAP5-2100

So it provides not the original event context(that was encoded in url) but
the context populated from parameter. And so it has no sence for now.



On Wed, Apr 24, 2013 at 4:21 PM, Michael Prescott 
michael.r.presc...@gmail.com wrote:

 Okay! I've filed it as https://issues.apache.org/jira/browse/TAP5-2111


 On 24 April 2013 09:07, Lance Java lance.j...@googlemail.com wrote:

  Far from being a gory detail, it's part of the public API for the mixin,
  very similar to AutoComplete's provideCompletions event.
 
  The mixin should ideally declare the event using @Events(refresh) and
  should have a mention in the javadoc too.
 




-- 
BR
Ivan


@BeginRender equivalent for component AJAX events

2013-04-23 Thread Michael Prescott
I have a component that includes a zone - the zone is periodically
refreshed using the ZoneRefresh mixin.

Is there any equivalent to @BeginRender that I can use to set up data to
support the zone re-rendering?  @BeginRender methods are called when the
page renders, but they're not called when the zone re-renders via ajax.

The only event I've found that gets called is @PageAttached, but of course
this is deprecated.

Any tips would be appreciated!

Gratefully,

Michael


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 geoff.callen...@mac.comwrote:

  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-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 
 geoff.callen...@mac.comwrote:
 
 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



[5.3.6] Listening to native tapestry ajax events

2012-12-15 Thread Muhammad Gelbana
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 ?

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 !

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

Thank you.


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()
   {
  CaptureResultCallbackObject callback = new 
CaptureResultCallbackObject();
  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

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: AJAX Events

2012-06-27 Thread Gep
I feel quite dumb, My issue was simply the capital o on my OnInc method
(becoming lazy about case sensitivy in Tapestry :p ).

Although, thank you for the requestParameter link!



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/AJAX-Events-tp2429263p5714109.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: AJAX Events

2012-06-26 Thread Gep
Sorry to dig out this post, but I'm having the exact same issue.

After having a look at :
http://samroyale.blogspot.fr/2009/11/controlling-ajax-in-tapestry.html I
tried to use this trick, but I failed.

In my page.java, I create a link this way:


With a simple OnInc method in the same page: 


Whether I click on the link triggering the event or goes directly to the
expected URL of the event, I get the same error message:


Does anyone have an idea why I can't manage to access the event?

Gep

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/AJAX-Events-tp2429263p5714097.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: AJAX Events

2012-06-26 Thread Ray Nicholus
Have a look at the RequestParameter annotation.

On Tue, Jun 26, 2012 at 11:05 AM, Gep gpo...@sopragroup.com wrote:

 Sorry to dig out this post, but I'm having the exact same issue.

 After having a look at :
 http://samroyale.blogspot.fr/2009/11/controlling-ajax-in-tapestry.html I
 tried to use this trick, but I failed.

 In my page.java, I create a link this way:


 With a simple OnInc method in the same page:


 Whether I click on the link triggering the event or goes directly to the
 expected URL of the event, I get the same error message:


 Does anyone have an idea why I can't manage to access the event?

 Gep

 --
 View this message in context:
 http://tapestry.1045711.n5.nabble.com/AJAX-Events-tp2429263p5714097.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.

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




Re: Ajax events, expired session and @Persist fields

2011-09-19 Thread Lenny Primak
I finally figured out how to handle Ajax events and sessions from the @XHR 
annotation.
It involved Thiago's suggested SessionState object, but as a means of 
communicating
between the annotation worker and the session state tracker.
The session state tracker turned out to be pretty complex, unfortunately.
I will try to get the results posted on the wiki along with other integrations 
that I had to go through.

Thanks for your help!

On Sep 19, 2011, at 1:00 AM, Lenny Primak wrote:

 I finally had a chance to try these methods, unfortunately with little 
 success.
 
 Yes, I can check only one @Persist field for null to see whether the session 
 still exists, which works.
 Request.getSession(false) does not really work, because a new (empty) session 
 can be created
 within this request by other parts of the code, which is correct behavior.  
 
 I tried the @XHR method as well, but I could not get the annotated method not 
 to get invoked at all.
 Whether I call 'invocation.proceed()' or not, the method would still get 
 invoked and throw NullPointerException.
 
 I would love to make @XHR method to work, just not call the Ajax method if 
 any of the @Persist variables are null, 
 but still no luck.
 
 Any other ideas?
 Thanks!
 
 On Sep 14, 2011, at 6:19 PM, Thiago H. de Paula Figueiredo wrote:
 
 On Wed, 14 Sep 2011 16:25:14 -0300, Lenny Primak lpri...@hope.nyc.ny.us 
 wrote:
 
 This is a design/best practices question.
 We set up @Persist fields inside @SetupRender method.
 When a session is invalid/expired and an Ajax event is called,
 All these fields at null.
 The question is if there is a better way to handle this situation than 
 having to check for Null in every Ajax event method for every @Persist 
 field?
 
 You don't need to check all of them, just whether Request.getSession(false) 
 returns null or not.
 
 I was thinking that @SetupRender should be called in case of session 
 expiration during Ajax call.
 
 I don't like this solution at all, as it uses a component event handler for 
 doing something completely unrelated to rendering. You can even write class 
 transformation to add some logic to be executed in AJAX requests when the 
 session isn't valid. Taha wrote something similar (the @XHR annotation) in 
 his Tapestry Magic blog: 
 http://tawus.wordpress.com/2011/04/16/tapestry-magic-2-ajax-with-graceful-degradation/.
 
 On the other hand, I guess it's possible to implement a service that 
 notifies listeners when the session is killed. I don't think it's possible 
 to discern between timeout and normal session invalidation.
 
 -- 
 Thiago H. de Paula Figueiredo
 Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and 
 instructor
 Owner, Ars Machina Tecnologia da Informação Ltda.
 http://www.arsmachina.com.br
 
 


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



Re: Ajax events, expired session and @Persist fields

2011-09-18 Thread Lenny Primak
I finally had a chance to try these methods, unfortunately with little success.

Yes, I can check only one @Persist field for null to see whether the session 
still exists, which works.
Request.getSession(false) does not really work, because a new (empty) session 
can be created
within this request by other parts of the code, which is correct behavior.  

I tried the @XHR method as well, but I could not get the annotated method not 
to get invoked at all.
Whether I call 'invocation.proceed()' or not, the method would still get 
invoked and throw NullPointerException.

I would love to make @XHR method to work, just not call the Ajax method if any 
of the @Persist variables are null, 
but still no luck.

Any other ideas?
Thanks!

On Sep 14, 2011, at 6:19 PM, Thiago H. de Paula Figueiredo wrote:

 On Wed, 14 Sep 2011 16:25:14 -0300, Lenny Primak lpri...@hope.nyc.ny.us 
 wrote:
 
 This is a design/best practices question.
 We set up @Persist fields inside @SetupRender method.
 When a session is invalid/expired and an Ajax event is called,
 All these fields at null.
 The question is if there is a better way to handle this situation than 
 having to check for Null in every Ajax event method for every @Persist field?
 
 You don't need to check all of them, just whether Request.getSession(false) 
 returns null or not.
 
 I was thinking that @SetupRender should be called in case of session 
 expiration during Ajax call.
 
 I don't like this solution at all, as it uses a component event handler for 
 doing something completely unrelated to rendering. You can even write class 
 transformation to add some logic to be executed in AJAX requests when the 
 session isn't valid. Taha wrote something similar (the @XHR annotation) in 
 his Tapestry Magic blog: 
 http://tawus.wordpress.com/2011/04/16/tapestry-magic-2-ajax-with-graceful-degradation/.
 
 On the other hand, I guess it's possible to implement a service that notifies 
 listeners when the session is killed. I don't think it's possible to discern 
 between timeout and normal session invalidation.
 
 -- 
 Thiago H. de Paula Figueiredo
 Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and 
 instructor
 Owner, Ars Machina Tecnologia da Informação Ltda.
 http://www.arsmachina.com.br
 


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



Re: Ajax events, expired session and @Persist fields

2011-09-15 Thread Lenny Primak
Thanks Thiago. I will try all these options and report the results. 



On Sep 14, 2011, at 5:19 PM, Thiago H. de Paula Figueiredo 
thiag...@gmail.com wrote:

 On Wed, 14 Sep 2011 16:25:14 -0300, Lenny Primak lpri...@hope.nyc.ny.us 
 wrote:
 
 This is a design/best practices question.
 We set up @Persist fields inside @SetupRender method.
 When a session is invalid/expired and an Ajax event is called,
 All these fields at null.
 The question is if there is a better way to handle this situation than 
 having to check for Null in every Ajax event method for every @Persist field?
 
 You don't need to check all of them, just whether Request.getSession(false) 
 returns null or not.
 
 I was thinking that @SetupRender should be called in case of session 
 expiration during Ajax call.
 
 I don't like this solution at all, as it uses a component event handler for 
 doing something completely unrelated to rendering. You can even write class 
 transformation to add some logic to be executed in AJAX requests when the 
 session isn't valid. Taha wrote something similar (the @XHR annotation) in 
 his Tapestry Magic blog: 
 http://tawus.wordpress.com/2011/04/16/tapestry-magic-2-ajax-with-graceful-degradation/.
 
 On the other hand, I guess it's possible to implement a service that notifies 
 listeners when the session is killed. I don't think it's possible to discern 
 between timeout and normal session invalidation.
 
 -- 
 Thiago H. de Paula Figueiredo
 Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and 
 instructor
 Owner, Ars Machina Tecnologia da Informação Ltda.
 http://www.arsmachina.com.br
 

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



Ajax events, expired session and @Persist fields

2011-09-14 Thread Lenny Primak
This is a design/best practices question. 
We set up @Persist fields inside @SetupRender method. 
When a session is invalid/expired and an Ajax event is called,
All these fields at null. 
The question is if there is a better way to handle this situation than having 
to check for Null in every Ajax event method for every @Persist field?

I was thinking that @SetupRender should be called in case of session expiration 
during Ajax call. Is there any way I can make this happen myself?  Or should I 
open a Jira and maybe that can be an enhancement to tapestry? 

Thanks for your help. 




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



Re: Ajax events, expired session and @Persist fields

2011-09-14 Thread Thiago H. de Paula Figueiredo
On Wed, 14 Sep 2011 16:25:14 -0300, Lenny Primak lpri...@hope.nyc.ny.us  
wrote:



This is a design/best practices question.
We set up @Persist fields inside @SetupRender method.
When a session is invalid/expired and an Ajax event is called,
All these fields at null.
The question is if there is a better way to handle this situation than  
having to check for Null in every Ajax event method for every @Persist  
field?


You don't need to check all of them, just whether  
Request.getSession(false) returns null or not.


I was thinking that @SetupRender should be called in case of session  
expiration during Ajax call.


I don't like this solution at all, as it uses a component event handler  
for doing something completely unrelated to rendering. You can even write  
class transformation to add some logic to be executed in AJAX requests  
when the session isn't valid. Taha wrote something similar (the @XHR  
annotation) in his Tapestry Magic blog:  
http://tawus.wordpress.com/2011/04/16/tapestry-magic-2-ajax-with-graceful-degradation/.


On the other hand, I guess it's possible to implement a service that  
notifies listeners when the session is killed. I don't think it's possible  
to discern between timeout and normal session invalidation.


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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



Re: AJAX Events

2009-02-25 Thread Thiago H. de Paula Figueiredo
Em Wed, 25 Feb 2009 08:07:18 -0300, Davor Miku davorm...@gmail.com  
escreveu:


Question is how can some arbitraryJavaScriptFunction() invoke  
corresponding Tapestry method?


Make your Javascript invoke an URL created by  
ComponentResources.createEventLink(). ;)


--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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



Re: AJAX Events

2009-02-25 Thread Robert Zeigler

Check out EventLink and/or ComponentResources.createEventLink. Like:

public class SomeComponent {
@Inject
private ComponentResources resources;

public String getEventLink() {
	return  
resources 
.createEventLink 
(MyCustomEventName,contextParameter1,contextParameter2,...);

}

void onMyCustomEventName() {
//do something interesting.
}

Robert

On Feb 25, 2009, at 2/255:07 AM , Davor Miku wrote:

Clicking on actionlink component, some Tapestry method is invoked  
(method

for action event).

Question is how can some arbitraryJavaScriptFunction() invoke  
corresponding

Tapestry method?

I'm not sure I'm clear enough.




On Wed, Feb 25, 2009 at 4:17 AM, Alex Kotchnev akoch...@gmail.com  
wrote:



Davor,
 what do you mean by when some div is dropped ? Can you please
describe in slightly more detail by custom events ?

Cheers,

Alex Kotchnev

On Mon, Feb 23, 2009 at 1:56 PM, Davor Miku davorm...@gmail.com  
wrote:



Hi!

I've found some tutorials for AJAX in Tapestry, but there all about

action

event, fired form actionlink component.

My questions is how to define custom events, i.e.. when some div  
is

dropped.

Thanks!






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



Re: AJAX Events

2009-02-24 Thread Alex Kotchnev
Davor,
   what do you mean by when some div is dropped ? Can you please
describe in slightly more detail by custom events ?

Cheers,

Alex Kotchnev

On Mon, Feb 23, 2009 at 1:56 PM, Davor Miku davorm...@gmail.com wrote:

 Hi!

 I've found some tutorials for AJAX in Tapestry, but there all about action
 event, fired form actionlink component.

 My questions is how to define custom events, i.e.. when some div is
 dropped.

 Thanks!



AJAX Events

2009-02-23 Thread Davor Miku
Hi!

I've found some tutorials for AJAX in Tapestry, but there all about action
event, fired form actionlink component.

My questions is how to define custom events, i.e.. when some div is
dropped.

Thanks!