Re: T5 - Catching user leaving a page

2008-10-23 Thread Otho
Since your problem is similar to serverpush functionality you might also
take a look into dwr. They have a chat example which you might use in your
Tapestry app.

Look here: http://directwebremoting.org/dwr/reverse-ajax


Re: T5 - Catching user leaving a page

2008-10-23 Thread BarryDev

Got the onbeforeunload call to work.  On the off chance that someone is doing
something similar here's my .tml head.

I'm using jQuery to do an ajax call with a onActionFromLink(String name)
method in my page to remove the user from my trusty singleton.  Interesting
gotcha, ie 6 caches all ajax calls by default hence the cache: false.  This
works in firefox 3 and ie 6.


chatroom Start Page




 var userName = '${currentUserName}';
  <!-- //
$(document).ready(function(){

window.onbeforeunload = removeUser

});

function removeUser(){

$.ajax({
type: "GET",
url: "chatroom.link/" + 
userName,
cache: false
});

}

// -->




-- 
View this message in context: 
http://www.nabble.com/T5---Catching-user-leaving-a-page-tp20093965p20129875.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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



Re: T5 - Catching user leaving a page

2008-10-22 Thread BarryDev


Thanks for the posts, I'm going to try using the onbeforeunload method, it
seems to have support in most recent browsers.  I'd if it works it seems
less error prone than a polling system.  

Is it possible to call methods on one of my tapestry page's methods from a
piece of custom javascript?

Thanks also for the pointers on the system design,  this is really just a
simple tech demo to play with tapestry at the moment so I'm not too
concerned with how it all hangs together.

Barry



dhning-2 wrote:
> 
> Hi, 
> 
> Maybe T5 would not have any solution for such case, I think this is a
> client browser issue, for server doesn't know user has changed
> url(SessionListener may know closing browser).
> 
> Maybe you can handle window event 'window.onbeforeunload'(it will be fired
> if closing browser, changing url, click lick and so on happen -- leaving
> current page), in IE it works, but I am not sure about others.
> 
> Thanks!
> 
> DH
> 
> 
> - Original Message - 
> From: "BarryDev" <[EMAIL PROTECTED]>
> To: 
> Sent: Wednesday, October 22, 2008 12:16 AM
> Subject: T5 - Catching user leaving a page
> 
> 
>> 
>> Hi all,
>> 
>> I've completed the hi/lo and address tutorial and I'm not trying to write
>> a
>> simple chatroom to learn some more about tapestry. 
>> 
>> My basic chatroom currently has a login page which forwards to a chatroom
>> which lists the usernames of all logged in users.  I'm currently using a
>> singleton to store all the users who are logged in and fetch them when
>> rendering the chatroom.
>> 
>> What I would like to do next is catch a user leaving the chatroom no
>> matter
>> what they're do (closing broswer, typing in new url, clicking a link in
>> the
>> app, hitting back button in browser) so I can remove them from the list
>> of
>> logged in users.
>> 
>> What's the best mechanism to do this with Tap5, is there a page detached
>> event I can register to that will get thrown in all cases?  Is it better
>> to
>> have a bit of javascript on the page which polls another page doing an
>> async
>> I'm still alive? (I'll probably need to do something like this for
>> polling
>> for new messages from other users)
>> 
>> Or is there a more elegant solution hidden within T5?  I've searched here
>> and the docs but haven't been able to find anything.
>> 
>> Regards
>> Barry
>> -- 
>> View this message in context:
>> http://www.nabble.com/T5---Catching-user-leaving-a-page-tp20093965p20093965.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>> 
>> 
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>> 
>>
> 

-- 
View this message in context: 
http://www.nabble.com/T5---Catching-user-leaving-a-page-tp20093965p20110310.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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



Re: T5 - Catching user leaving a page

2008-10-21 Thread Ville Virtanen

Forgot to mention that I think that the chat system should be a service or
series of services that probably keep the state of the chat room via db back
end (using suitable amount of on memory cache). Then there would be the
still alive poll page that would only signal the service that user is still
there, then a page where the actual chat would be. The chat page could be
also broken to smaller chunks to improve performance. (One page could supply
the contents of currently active chat members etc, and the other could
supply the incoming / outgoing messages.)

Haven't done anything like that, but that would be the path that I would
take. No guarantees though :D

 - Ville


BarryDev wrote:
> 
> Hi all,
> 
> I've completed the hi/lo and address tutorial and I'm not trying to write
> a simple chatroom to learn some more about tapestry. 
> 
> My basic chatroom currently has a login page which forwards to a chatroom
> which lists the usernames of all logged in users.  I'm currently using a
> singleton to store all the users who are logged in and fetch them when
> rendering the chatroom.
> 
> What I would like to do next is catch a user leaving the chatroom no
> matter what they're do (closing broswer, typing in new url, clicking a
> link in the app, hitting back button in browser) so I can remove them from
> the list of logged in users.
> 
> What's the best mechanism to do this with Tap5, is there a page detached
> event I can register to that will get thrown in all cases?  Is it better
> to have a bit of javascript on the page which polls another page doing an
> async I'm still alive? (I'll probably need to do something like this for
> polling for new messages from other users)
> 
> Or is there a more elegant solution hidden within T5?  I've searched here
> and the docs but haven't been able to find anything.
> 
> Regards
> Barry
> 

-- 
View this message in context: 
http://www.nabble.com/T5---Catching-user-leaving-a-page-tp20093965p20104801.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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



Re: T5 - Catching user leaving a page

2008-10-21 Thread Ville Virtanen

This is more a limitation or the nature of the http and other protocols than
a defect in T5. 

The polling scheme is only possibility that comes to my mind. If the user
has not been heard of for a certain amount of time, he/she will be regarded
as absent and removed from the room. Of course, what ever the user does to
the client to move to another page stops the javascript that is sending the
"still alive messages".

You're going to have to write some custom js to do this, there isn't needed
functionality in T5 that would do this AFAIK.

 - Ville


BarryDev wrote:
> 
> Hi all,
> 
> I've completed the hi/lo and address tutorial and I'm not trying to write
> a simple chatroom to learn some more about tapestry. 
> 
> My basic chatroom currently has a login page which forwards to a chatroom
> which lists the usernames of all logged in users.  I'm currently using a
> singleton to store all the users who are logged in and fetch them when
> rendering the chatroom.
> 
> What I would like to do next is catch a user leaving the chatroom no
> matter what they're do (closing broswer, typing in new url, clicking a
> link in the app, hitting back button in browser) so I can remove them from
> the list of logged in users.
> 
> What's the best mechanism to do this with Tap5, is there a page detached
> event I can register to that will get thrown in all cases?  Is it better
> to have a bit of javascript on the page which polls another page doing an
> async I'm still alive? (I'll probably need to do something like this for
> polling for new messages from other users)
> 
> Or is there a more elegant solution hidden within T5?  I've searched here
> and the docs but haven't been able to find anything.
> 
> Regards
> Barry
> 

-- 
View this message in context: 
http://www.nabble.com/T5---Catching-user-leaving-a-page-tp20093965p20104676.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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



Re: T5 - Catching user leaving a page

2008-10-21 Thread dhning
Hi, 

Maybe T5 would not have any solution for such case, I think this is a client 
browser issue, for server doesn't know user has changed url(SessionListener may 
know closing browser).

Maybe you can handle window event 'window.onbeforeunload'(it will be fired if 
closing browser, changing url, click lick and so on happen -- leaving current 
page), in IE it works, but I am not sure about others.

Thanks!

DH


- Original Message - 
From: "BarryDev" <[EMAIL PROTECTED]>
To: 
Sent: Wednesday, October 22, 2008 12:16 AM
Subject: T5 - Catching user leaving a page


> 
> Hi all,
> 
> I've completed the hi/lo and address tutorial and I'm not trying to write a
> simple chatroom to learn some more about tapestry. 
> 
> My basic chatroom currently has a login page which forwards to a chatroom
> which lists the usernames of all logged in users.  I'm currently using a
> singleton to store all the users who are logged in and fetch them when
> rendering the chatroom.
> 
> What I would like to do next is catch a user leaving the chatroom no matter
> what they're do (closing broswer, typing in new url, clicking a link in the
> app, hitting back button in browser) so I can remove them from the list of
> logged in users.
> 
> What's the best mechanism to do this with Tap5, is there a page detached
> event I can register to that will get thrown in all cases?  Is it better to
> have a bit of javascript on the page which polls another page doing an async
> I'm still alive? (I'll probably need to do something like this for polling
> for new messages from other users)
> 
> Or is there a more elegant solution hidden within T5?  I've searched here
> and the docs but haven't been able to find anything.
> 
> Regards
> Barry
> -- 
> View this message in context: 
> http://www.nabble.com/T5---Catching-user-leaving-a-page-tp20093965p20093965.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

T5 - Catching user leaving a page

2008-10-21 Thread BarryDev

Hi all,

I've completed the hi/lo and address tutorial and I'm not trying to write a
simple chatroom to learn some more about tapestry. 

My basic chatroom currently has a login page which forwards to a chatroom
which lists the usernames of all logged in users.  I'm currently using a
singleton to store all the users who are logged in and fetch them when
rendering the chatroom.

What I would like to do next is catch a user leaving the chatroom no matter
what they're do (closing broswer, typing in new url, clicking a link in the
app, hitting back button in browser) so I can remove them from the list of
logged in users.

What's the best mechanism to do this with Tap5, is there a page detached
event I can register to that will get thrown in all cases?  Is it better to
have a bit of javascript on the page which polls another page doing an async
I'm still alive? (I'll probably need to do something like this for polling
for new messages from other users)

Or is there a more elegant solution hidden within T5?  I've searched here
and the docs but haven't been able to find anything.

Regards
Barry
-- 
View this message in context: 
http://www.nabble.com/T5---Catching-user-leaving-a-page-tp20093965p20093965.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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