[Lift] Re: execute code when browser is closed

2009-10-06 Thread Timothy Perrett
Hey jack,

As I said before, I think the design you have is wrong if your needing  
to code in a hacky way such as this. The way you articulate the  
justification for using shutdown almost certianly clarifies an  
incorrect design.

Personally I think you could use Ajax for this an have a much simpler  
design of system... I would tend to recomend using comet when you have  
some server side state that changes and needs update client side  
continually. Kinda feel it's hammer to crack a nut here, but perhaps  
that's just me.

Hope you get it sorted :-)

Cheers, Tim

Sent from my iPhone

On 6 Oct 2009, at 05:25, Jack Widman jack.wid...@gmail.com wrote:

 So I am using a snippet like this

  def go:NodeSeq = {
 var term:String = S.param(term).openOr()
 lift:surround with=default at=content
 lift:comet type=JoopComet name={term}
 auth:joop/auth:joop
 /lift:comet
 /lift:surround
   }

 And the term is indeed different each time. But I am still getting  
 the same results from two different browsers with different terms.

 On Tue, Oct 6, 2009 at 12:18 AM, Naftoli Gugenheim naftoli...@gmail.com 
  wrote:

 You are correct that Comet is a way to update information after the  
 page is loaded. I think there's a simpler way using ajax, but I  
 haven't explored those areas of Lift yet. But meanwhile you need to  
 have the xml specifying the comet actor be dynamic. So you need to  
 have that xml be generated by a snippet. A snippet is an XML to XML  
 function.


 -
 jackjack.wid...@gmail.com wrote:


 Let me start again. Maybe I am misunderstanding when Comet should be
 used. In my application, people search for web pages. I do a lot of
 processing for each resulting page. First I just display the links and
 then as the processing is finished, the links on the page are
 automatically modified with the data I just found for each link. This
 is all working fine.

 But, the session is being shared among all users so if I make one
 search in one browser, and then make another search from another
 browser, I get the results from the first browser.

 David suggested I name each CometActor differently. That is not
 working, though maybe I am not doing it right.

 On Oct 6, 12:01 am, Naftoli Gugenheim naftoli...@gmail.com wrote:
  What do you mean?
 
  -
 
  jackjack.wid...@gmail.com wrote:
 
  i guess you meant put the snippet right in the CometActor. Ok. Now  
 I'm
  getting it.
 
  On Oct 5, 11:46 pm, Jack Widman jack.wid...@gmail.com wrote:
 
 
 
   Sorry if this is a dumb question but in lift:comet type=Search
   name={searchString}/, what is searchString? This is in an html  
 file. I am
   obviously missing something.
 
   On Mon, Oct 5, 2009 at 2:40 PM, David Pollak
   feeder.of.the.be...@gmail.comwrote:
 
On Mon, Oct 5, 2009 at 10:27 AM, Jack Widman  
 jack.wid...@gmail.comwrote:
 
Understood. My intention is to send a ShutDown message to the  
 CometActor
when somebody closes the browser. I need this so that when  
 they visit the
page in a browser again, the CometActor is 'reset'.
 
First, there's no way to determine if the browser window is  
 closed.
 
Second, *DO NOT* send a ShutDown message to the CometActor.   
 This is an
internal Lift piece of housekeeping.  If you do this, you will  
 break stuff.
 Don't do it.  (There is a reason the message is not private,  
 but it should
not be used for this purpose.)
 
CometActors can be named:
 
lift:comet type=Search name={searchString}/
 
You can then have a separate CometActor for each  
 searchString.  Voila...
you get what you want.  Now, how do you make then CometActor  
 go away when
it's not being used anymore?
 
In your CometActor:
 override def lifespan: Box[TimeSpan] = Full(3 minutes)
 
That means if a CometActor does not appear on a page for 3  
 minutes, it's
removed from the session.  If the named CometActor is  
 requested again, a new
one will be created.
 
On Mon, Oct 5, 2009 at 1:18 PM, marius d.  
 marius.dan...@gmail.comwrote:
 
HTTP session termination does not equate with browser-close  
 event.
 
Br's,
Marius
 
On Oct 5, 3:22 pm, Jack Widman jack.wid...@gmail.com wrote:
 Yes, thats what I meant. Thanks
 
 On Mon, Oct 5, 2009 at 4:10 AM, Timothy Perrett
timo...@getintheloop.euwrote:
 
  But you can do it on session termination (which is what  
 you probably
  want):
 
   http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scalado 
 ...
 
  Checkout the method:
 
  registerCleanupFunc
 
  Cheers, Tim
 
  On Oct 5, 8:54 am, Viktor Klang viktor.kl...@gmail.com  
 wrote:
   On Mon, Oct 5, 2009 at 6:50 AM, jack  
 jack.wid...@gmail.com
wrote:
 
I would like to call a function when the browser is  
 closed. How
do I
do this?
 
   You cannot reliably do this.
 
   --
   

[Lift] Re: execute code when browser is closed

2009-10-06 Thread Jack Widman
I didn't mean to sound like I am justifying the way I am doing. I definitely
do not have a good feel for lift yet and  it feels hackey to me too. Part of
it is I'm rushing to get a demo done at the same time I am learning lift.
Thanks for your help.

On Tue, Oct 6, 2009 at 2:04 AM, Timothy Perrett timo...@getintheloop.euwrote:

 Hey jack,

 As I said before, I think the design you have is wrong if your needing to
 code in a hacky way such as this. The way you articulate the justification
 for using shutdown almost certianly clarifies an incorrect design.

 Personally I think you could use Ajax for this an have a much simpler
 design of system... I would tend to recomend using comet when you have some
 server side state that changes and needs update client side continually.
 Kinda feel it's hammer to crack a nut here, but perhaps that's just me.

 Hope you get it sorted :-)

 Cheers, Tim

 Sent from my iPhone

 On 6 Oct 2009, at 05:25, Jack Widman jack.wid...@gmail.com wrote:

 So I am using a snippet like this
  def go:NodeSeq = {
 var term:String = S.param(term).openOr()
 lift:surround with=default at=content
 lift:comet type=JoopComet name={term}
 auth:joop/auth:joop
 /lift:comet
 /lift:surround
   }

 And the term is indeed different each time. But I am still getting the same
 results from two different browsers with different terms.

 On Tue, Oct 6, 2009 at 12:18 AM, Naftoli Gugenheim naftoli...@gmail.com
 naftoli...@gmail.com wrote:


 You are correct that Comet is a way to update information after the page
 is loaded. I think there's a simpler way using ajax, but I haven't explored
 those areas of Lift yet. But meanwhile you need to have the xml specifying
 the comet actor be dynamic. So you need to have that xml be generated by a
 snippet. A snippet is an XML to XML function.


 -
 jack jack.wid...@gmail.comjack.wid...@gmail.com wrote:


 Let me start again. Maybe I am misunderstanding when Comet should be
 used. In my application, people search for web pages. I do a lot of
 processing for each resulting page. First I just display the links and
 then as the processing is finished, the links on the page are
 automatically modified with the data I just found for each link. This
 is all working fine.

 But, the session is being shared among all users so if I make one
 search in one browser, and then make another search from another
 browser, I get the results from the first browser.

 David suggested I name each CometActor differently. That is not
 working, though maybe I am not doing it right.

 On Oct 6, 12:01 am, Naftoli Gugenheim naftoli...@gmail.com wrote:
  What do you mean?
 
  -
 
  jackjack.wid...@gmail.com wrote:
 
  i guess you meant put the snippet right in the CometActor. Ok. Now I'm
  getting it.
 
  On Oct 5, 11:46 pm, Jack Widman jack.wid...@gmail.com wrote:
 
 
 
   Sorry if this is a dumb question but in lift:comet type=Search
   name={searchString}/, what is searchString? This is in an html file.
 I am
   obviously missing something.
 
   On Mon, Oct 5, 2009 at 2:40 PM, David Pollak
feeder.of.the.be...@gmail.comfeeder.of.the.be...@gmail.comwrote:
 
On Mon, Oct 5, 2009 at 10:27 AM, Jack Widman jack.wid...@gmail.com
 wrote:
 
Understood. My intention is to send a ShutDown message to the
 CometActor
when somebody closes the browser. I need this so that when they
 visit the
page in a browser again, the CometActor is 'reset'.
 
First, there's no way to determine if the browser window is closed.
 
Second, *DO NOT* send a ShutDown message to the CometActor.  This is
 an
internal Lift piece of housekeeping.  If you do this, you will break
 stuff.
 Don't do it.  (There is a reason the message is not private, but it
 should
not be used for this purpose.)
 
CometActors can be named:
 
lift:comet type=Search name={searchString}/
 
You can then have a separate CometActor for each searchString.
  Voila...
you get what you want.  Now, how do you make then CometActor go away
 when
it's not being used anymore?
 
In your CometActor:
 override def lifespan: Box[TimeSpan] = Full(3 minutes)
 
That means if a CometActor does not appear on a page for 3 minutes,
 it's
removed from the session.  If the named CometActor is requested
 again, a new
one will be created.
 
On Mon, Oct 5, 2009 at 1:18 PM, marius d. marius.dan...@gmail.com
 wrote:
 
HTTP session termination does not equate with browser-close event.
 
Br's,
Marius
 
On Oct 5, 3:22 pm, Jack Widman jack.wid...@gmail.com wrote:
 Yes, thats what I meant. Thanks
 
 On Mon, Oct 5, 2009 at 4:10 AM, Timothy Perrett
timo...@getintheloop.euwrote:
 
  But you can do it on session termination (which is what you
 probably
  want):
 
   http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scalado.
 

[Lift] Re: execute code when browser is closed

2009-10-06 Thread Ross Mellgren

I'm pretty tired and I definitely did not try to compile this, but  
maybe something like this using plain ajax might be better? If the  
server cannot be contacted an alert box will pop up -- you can  
customize that behavior using AjaxContext and using that with  
SHtml.ajaxCall or jsonCall, I think.

-Ross



import scala.xml.NodeSeq
import net.liftweb.http.{S, SHtml, StatefulSnippet}
import net.liftweb.http.js.{JE, JsCmds}
import net.liftweb.util.Box.option2Box
import net.liftweb.util.TimeHelpers.intToTimeSpan

class Searcher extends StatefulSnippet
{
 // FIXME use something to keep track of already displayed results  
and only push updates
 var results: List[String] = Nil
 var done: Boolean

 def search(ns: NodeSeq): NodeSeq = S.param(term).map(term = {
 val resultsId = attr(id).openOr(search-results)

 // kick off some thread that updates results and done  
searching for term

 head{ JsCmds.Script(
 JsCmds.JsCrVar(updateResults, JE.AnonFunc 
(SHtml.ajaxInvoke(() = updateResults(resultsId))._2))
 JsCmds.After(5 seconds, JE.Call(updateResults))
 ) }/head ++
 div
 Searching for { term }
 div id={ resultsId } /
 /div
 })

 def updateResults(id: String): JsCmd =
 JsCmds.SetHtml(id, results.map(result = div{ result }/ 
div)) 
if (!done) {
 JsCmds.After(1 second, JE.Call(updateResults))
 } else {
JsCmds.Noop
 }


On Oct 6, 2009, at 2:07 AM, Jack Widman wrote:

 I didn't mean to sound like I am justifying the way I am doing. I  
 definitely do not have a good feel for lift yet and  it feels hackey  
 to me too. Part of it is I'm rushing to get a demo done at the same  
 time I am learning lift. Thanks for your help.

 On Tue, Oct 6, 2009 at 2:04 AM, Timothy Perrett timo...@getintheloop.eu 
  wrote:
 Hey jack,

 As I said before, I think the design you have is wrong if your  
 needing to code in a hacky way such as this. The way you articulate  
 the justification for using shutdown almost certianly clarifies an  
 incorrect design.

 Personally I think you could use Ajax for this an have a much  
 simpler design of system... I would tend to recomend using comet  
 when you have some server side state that changes and needs update  
 client side continually. Kinda feel it's hammer to crack a nut here,  
 but perhaps that's just me.

 Hope you get it sorted :-)

 Cheers, Tim

 Sent from my iPhone

 On 6 Oct 2009, at 05:25, Jack Widman jack.wid...@gmail.com wrote:

 So I am using a snippet like this

  def go:NodeSeq = {
 var term:String = S.param(term).openOr()
 lift:surround with=default at=content
 lift:comet type=JoopComet name={term}
 auth:joop/auth:joop
 /lift:comet
 /lift:surround
   }

 And the term is indeed different each time. But I am still getting  
 the same results from two different browsers with different terms.

 On Tue, Oct 6, 2009 at 12:18 AM, Naftoli Gugenheim naftoli...@gmail.com 
  wrote:

 You are correct that Comet is a way to update information after the  
 page is loaded. I think there's a simpler way using ajax, but I  
 haven't explored those areas of Lift yet. But meanwhile you need to  
 have the xml specifying the comet actor be dynamic. So you need to  
 have that xml be generated by a snippet. A snippet is an XML to XML  
 function.


 -
 jackjack.wid...@gmail.com wrote:


 Let me start again. Maybe I am misunderstanding when Comet should be
 used. In my application, people search for web pages. I do a lot of
 processing for each resulting page. First I just display the links  
 and
 then as the processing is finished, the links on the page are
 automatically modified with the data I just found for each link. This
 is all working fine.

 But, the session is being shared among all users so if I make one
 search in one browser, and then make another search from another
 browser, I get the results from the first browser.

 David suggested I name each CometActor differently. That is not
 working, though maybe I am not doing it right.

 On Oct 6, 12:01 am, Naftoli Gugenheim naftoli...@gmail.com wrote:
  What do you mean?
 
  -
 
  jackjack.wid...@gmail.com wrote:
 
  i guess you meant put the snippet right in the CometActor. Ok.  
 Now I'm
  getting it.
 
  On Oct 5, 11:46 pm, Jack Widman jack.wid...@gmail.com wrote:
 
 
 
   Sorry if this is a dumb question but in lift:comet type=Search
   name={searchString}/, what is searchString? This is in an html  
 file. I am
   obviously missing something.
 
   On Mon, Oct 5, 2009 at 2:40 PM, David Pollak
   feeder.of.the.be...@gmail.comwrote:
 
On Mon, Oct 5, 2009 at 10:27 AM, Jack Widman  
 jack.wid...@gmail.comwrote:
 
Understood. My intention is to send a ShutDown message to  
 the CometActor
when somebody closes the browser. I need this so that when  
 

[Lift] Re: execute code when browser is closed

2009-10-06 Thread Naftoli Gugenheim

As Tim said, but in different words.
Use Comet when changed state needs to be *pushed* from the server.
Use Ajax when you need to asynchronously *pull* data from the server.
 

-
Ross Mellgrendri...@gmail.com wrote:


I'm pretty tired and I definitely did not try to compile this, but  
maybe something like this using plain ajax might be better? If the  
server cannot be contacted an alert box will pop up -- you can  
customize that behavior using AjaxContext and using that with  
SHtml.ajaxCall or jsonCall, I think.

-Ross



import scala.xml.NodeSeq
import net.liftweb.http.{S, SHtml, StatefulSnippet}
import net.liftweb.http.js.{JE, JsCmds}
import net.liftweb.util.Box.option2Box
import net.liftweb.util.TimeHelpers.intToTimeSpan

class Searcher extends StatefulSnippet
{
 // FIXME use something to keep track of already displayed results  
and only push updates
 var results: List[String] = Nil
 var done: Boolean

 def search(ns: NodeSeq): NodeSeq = S.param(term).map(term = {
 val resultsId = attr(id).openOr(search-results)

 // kick off some thread that updates results and done  
searching for term

 head{ JsCmds.Script(
 JsCmds.JsCrVar(updateResults, JE.AnonFunc 
(SHtml.ajaxInvoke(() = updateResults(resultsId))._2))
 JsCmds.After(5 seconds, JE.Call(updateResults))
 ) }/head ++
 div
 Searching for { term }
 div id={ resultsId } /
 /div
 })

 def updateResults(id: String): JsCmd =
 JsCmds.SetHtml(id, results.map(result = div{ result }/ 
div)) 
if (!done) {
 JsCmds.After(1 second, JE.Call(updateResults))
 } else {
JsCmds.Noop
 }


On Oct 6, 2009, at 2:07 AM, Jack Widman wrote:

 I didn't mean to sound like I am justifying the way I am doing. I  
 definitely do not have a good feel for lift yet and  it feels hackey  
 to me too. Part of it is I'm rushing to get a demo done at the same  
 time I am learning lift. Thanks for your help.

 On Tue, Oct 6, 2009 at 2:04 AM, Timothy Perrett timo...@getintheloop.eu 
  wrote:
 Hey jack,

 As I said before, I think the design you have is wrong if your  
 needing to code in a hacky way such as this. The way you articulate  
 the justification for using shutdown almost certianly clarifies an  
 incorrect design.

 Personally I think you could use Ajax for this an have a much  
 simpler design of system... I would tend to recomend using comet  
 when you have some server side state that changes and needs update  
 client side continually. Kinda feel it's hammer to crack a nut here,  
 but perhaps that's just me.

 Hope you get it sorted :-)

 Cheers, Tim

 Sent from my iPhone

 On 6 Oct 2009, at 05:25, Jack Widman jack.wid...@gmail.com wrote:

 So I am using a snippet like this

  def go:NodeSeq = {
 var term:String = S.param(term).openOr()
 lift:surround with=default at=content
 lift:comet type=JoopComet name={term}
 auth:joop/auth:joop
 /lift:comet
 /lift:surround
   }

 And the term is indeed different each time. But I am still getting  
 the same results from two different browsers with different terms.

 On Tue, Oct 6, 2009 at 12:18 AM, Naftoli Gugenheim naftoli...@gmail.com 
  wrote:

 You are correct that Comet is a way to update information after the  
 page is loaded. I think there's a simpler way using ajax, but I  
 haven't explored those areas of Lift yet. But meanwhile you need to  
 have the xml specifying the comet actor be dynamic. So you need to  
 have that xml be generated by a snippet. A snippet is an XML to XML  
 function.


 -
 jackjack.wid...@gmail.com wrote:


 Let me start again. Maybe I am misunderstanding when Comet should be
 used. In my application, people search for web pages. I do a lot of
 processing for each resulting page. First I just display the links  
 and
 then as the processing is finished, the links on the page are
 automatically modified with the data I just found for each link. This
 is all working fine.

 But, the session is being shared among all users so if I make one
 search in one browser, and then make another search from another
 browser, I get the results from the first browser.

 David suggested I name each CometActor differently. That is not
 working, though maybe I am not doing it right.

 On Oct 6, 12:01 am, Naftoli Gugenheim naftoli...@gmail.com wrote:
  What do you mean?
 
  -
 
  jackjack.wid...@gmail.com wrote:
 
  i guess you meant put the snippet right in the CometActor. Ok.  
 Now I'm
  getting it.
 
  On Oct 5, 11:46 pm, Jack Widman jack.wid...@gmail.com wrote:
 
 
 
   Sorry if this is a dumb question but in lift:comet type=Search
   name={searchString}/, what is searchString? This is in an html  
 file. I am
   obviously missing something.
 
   On Mon, Oct 5, 2009 at 2:40 PM, David Pollak
   

[Lift] Re: execute code when browser is closed

2009-10-05 Thread Viktor Klang
On Mon, Oct 5, 2009 at 6:50 AM, jack jack.wid...@gmail.com wrote:


 I would like to call a function when the browser is closed. How do I
 do this?


You cannot reliably do this.


 



-- 
Viktor Klang

Blog: klangism.blogspot.com
Twttr: viktorklang

Lift Committer - liftweb.com
AKKA Committer - akkasource.org
Cassidy - github.com/viktorklang/Cassidy.git
SoftPub founder: http://groups.google.com/group/softpub

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: execute code when browser is closed

2009-10-05 Thread Timothy Perrett

But you can do it on session termination (which is what you probably
want):

http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scaladocs/net/liftweb/http/SessionVar.html

Checkout the method:

registerCleanupFunc

Cheers, Tim

On Oct 5, 8:54 am, Viktor Klang viktor.kl...@gmail.com wrote:
 On Mon, Oct 5, 2009 at 6:50 AM, jack jack.wid...@gmail.com wrote:

  I would like to call a function when the browser is closed. How do I
  do this?

 You cannot reliably do this.



 --
 Viktor Klang

 Blog: klangism.blogspot.com
 Twttr: viktorklang

 Lift Committer - liftweb.com
 AKKA Committer - akkasource.org
 Cassidy - github.com/viktorklang/Cassidy.git
 SoftPub founder:http://groups.google.com/group/softpub
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: execute code when browser is closed

2009-10-05 Thread marius d.

HTTP session termination does not equate with browser-close event.

Br's,
Marius

On Oct 5, 3:22 pm, Jack Widman jack.wid...@gmail.com wrote:
 Yes, thats what I meant. Thanks

 On Mon, Oct 5, 2009 at 4:10 AM, Timothy Perrett 
 timo...@getintheloop.euwrote:





  But you can do it on session termination (which is what you probably
  want):

 http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scalado...

  Checkout the method:

  registerCleanupFunc

  Cheers, Tim

  On Oct 5, 8:54 am, Viktor Klang viktor.kl...@gmail.com wrote:
   On Mon, Oct 5, 2009 at 6:50 AM, jack jack.wid...@gmail.com wrote:

I would like to call a function when the browser is closed. How do I
do this?

   You cannot reliably do this.

   --
   Viktor Klang

   Blog: klangism.blogspot.com
   Twttr: viktorklang

   Lift Committer - liftweb.com
   AKKA Committer - akkasource.org
   Cassidy - github.com/viktorklang/Cassidy.git
   SoftPub founder:http://groups.google.com/group/softpub

 --
 Jack
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: execute code when browser is closed

2009-10-05 Thread Jack Widman
Understood. My intention is to send a ShutDown message to the CometActor
when somebody closes the browser. I need this so that when they visit the
page in a browser again, the CometActor is 'reset'.

On Mon, Oct 5, 2009 at 1:18 PM, marius d. marius.dan...@gmail.com wrote:


 HTTP session termination does not equate with browser-close event.

 Br's,
 Marius

 On Oct 5, 3:22 pm, Jack Widman jack.wid...@gmail.com wrote:
  Yes, thats what I meant. Thanks
 
  On Mon, Oct 5, 2009 at 4:10 AM, Timothy Perrett timo...@getintheloop.eu
 wrote:
 
 
 
 
 
   But you can do it on session termination (which is what you probably
   want):
 
  http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scalado.
 ..
 
   Checkout the method:
 
   registerCleanupFunc
 
   Cheers, Tim
 
   On Oct 5, 8:54 am, Viktor Klang viktor.kl...@gmail.com wrote:
On Mon, Oct 5, 2009 at 6:50 AM, jack jack.wid...@gmail.com wrote:
 
 I would like to call a function when the browser is closed. How do
 I
 do this?
 
You cannot reliably do this.
 
--
Viktor Klang
 
Blog: klangism.blogspot.com
Twttr: viktorklang
 
Lift Committer - liftweb.com
AKKA Committer - akkasource.org
Cassidy - github.com/viktorklang/Cassidy.git
SoftPub founder:http://groups.google.com/group/softpub
 
  --
  Jack
 



-- 
Jack

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: execute code when browser is closed

2009-10-05 Thread Jack Widman
Interesting. I will try that. And I won't send any more ShutDownMessages :)
Though I should add that each CometActor is doing a lot of processing. So I
it would be good if I could shut one down somehow when the user searches on
a new term. Timeout won't work because there is no way to know how long it
will take.

Maybe I could just kill all the actors directly that are doing the
processing.

On Mon, Oct 5, 2009 at 2:40 PM, David Pollak
feeder.of.the.be...@gmail.comwrote:



 On Mon, Oct 5, 2009 at 10:27 AM, Jack Widman jack.wid...@gmail.comwrote:

 Understood. My intention is to send a ShutDown message to the CometActor
 when somebody closes the browser. I need this so that when they visit the
 page in a browser again, the CometActor is 'reset'.


 First, there's no way to determine if the browser window is closed.

 Second, *DO NOT* send a ShutDown message to the CometActor.  This is an
 internal Lift piece of housekeeping.  If you do this, you will break stuff.
  Don't do it.  (There is a reason the message is not private, but it should
 not be used for this purpose.)

 CometActors can be named:

 lift:comet type=Search name={searchString}/

 You can then have a separate CometActor for each searchString.  Voila...
 you get what you want.  Now, how do you make then CometActor go away when
 it's not being used anymore?

 In your CometActor:
  override def lifespan: Box[TimeSpan] = Full(3 minutes)

 That means if a CometActor does not appear on a page for 3 minutes, it's
 removed from the session.  If the named CometActor is requested again, a new
 one will be created.




 On Mon, Oct 5, 2009 at 1:18 PM, marius d. marius.dan...@gmail.comwrote:


 HTTP session termination does not equate with browser-close event.

 Br's,
 Marius

 On Oct 5, 3:22 pm, Jack Widman jack.wid...@gmail.com wrote:
  Yes, thats what I meant. Thanks
 
  On Mon, Oct 5, 2009 at 4:10 AM, Timothy Perrett
 timo...@getintheloop.euwrote:
 
 
 
 
 
   But you can do it on session termination (which is what you probably
   want):
 
  
 http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scalado...
 
   Checkout the method:
 
   registerCleanupFunc
 
   Cheers, Tim
 
   On Oct 5, 8:54 am, Viktor Klang viktor.kl...@gmail.com wrote:
On Mon, Oct 5, 2009 at 6:50 AM, jack jack.wid...@gmail.com
 wrote:
 
 I would like to call a function when the browser is closed. How
 do I
 do this?
 
You cannot reliably do this.
 
--
Viktor Klang
 
Blog: klangism.blogspot.com
Twttr: viktorklang
 
Lift Committer - liftweb.com
AKKA Committer - akkasource.org
Cassidy - github.com/viktorklang/Cassidy.git
SoftPub founder:http://groups.google.com/group/softpub
 
  --
  Jack




 --
 Jack





 --
 Lift, the simply functional web framework http://liftweb.net
 Beginning Scala http://www.apress.com/book/view/1430219890
 Follow me: http://twitter.com/dpp
 Surf the harmonics


 



-- 
Jack

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: execute code when browser is closed

2009-10-05 Thread David Pollak
On Mon, Oct 5, 2009 at 11:45 AM, Jack Widman jack.wid...@gmail.com wrote:

 Interesting. I will try that. And I won't send any more ShutDownMessages :)
 Though I should add that each CometActor is doing a lot of processing. So I
 it would be good if I could shut one down somehow when the user searches on
 a new term. Timeout won't work because there is no way to know how long it
 will take.

 Maybe I could just kill all the actors directly that are doing the
 processing.


That's going to be even worse.  You'll kill something out from under Lift...
it's going to cause a huge pile of pain.

You can remove an Actor from the session and that will cause ShutDown to be
sent to it, but depending on how the Actor was written it's not going to
stop processing its mailbox.

Bottom line... there's no way to tell if a user is not looking at a page
with an Actor anymore.  The best way to deal with that is timing the Actor
out.  It's going to take time (your timeout period), but it's the best way
to do it.



 On Mon, Oct 5, 2009 at 2:40 PM, David Pollak 
 feeder.of.the.be...@gmail.com wrote:



 On Mon, Oct 5, 2009 at 10:27 AM, Jack Widman jack.wid...@gmail.comwrote:

 Understood. My intention is to send a ShutDown message to the CometActor
 when somebody closes the browser. I need this so that when they visit the
 page in a browser again, the CometActor is 'reset'.


 First, there's no way to determine if the browser window is closed.

 Second, *DO NOT* send a ShutDown message to the CometActor.  This is an
 internal Lift piece of housekeeping.  If you do this, you will break stuff.
  Don't do it.  (There is a reason the message is not private, but it should
 not be used for this purpose.)

 CometActors can be named:

 lift:comet type=Search name={searchString}/

 You can then have a separate CometActor for each searchString.  Voila...
 you get what you want.  Now, how do you make then CometActor go away when
 it's not being used anymore?

 In your CometActor:
  override def lifespan: Box[TimeSpan] = Full(3 minutes)

 That means if a CometActor does not appear on a page for 3 minutes, it's
 removed from the session.  If the named CometActor is requested again, a new
 one will be created.




 On Mon, Oct 5, 2009 at 1:18 PM, marius d. marius.dan...@gmail.comwrote:


 HTTP session termination does not equate with browser-close event.

 Br's,
 Marius

 On Oct 5, 3:22 pm, Jack Widman jack.wid...@gmail.com wrote:
  Yes, thats what I meant. Thanks
 
  On Mon, Oct 5, 2009 at 4:10 AM, Timothy Perrett
 timo...@getintheloop.euwrote:
 
 
 
 
 
   But you can do it on session termination (which is what you probably
   want):
 
  
 http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scalado.
 ..
 
   Checkout the method:
 
   registerCleanupFunc
 
   Cheers, Tim
 
   On Oct 5, 8:54 am, Viktor Klang viktor.kl...@gmail.com wrote:
On Mon, Oct 5, 2009 at 6:50 AM, jack jack.wid...@gmail.com
 wrote:
 
 I would like to call a function when the browser is closed. How
 do I
 do this?
 
You cannot reliably do this.
 
--
Viktor Klang
 
Blog: klangism.blogspot.com
Twttr: viktorklang
 
Lift Committer - liftweb.com
AKKA Committer - akkasource.org
Cassidy - github.com/viktorklang/Cassidy.git
SoftPub founder:http://groups.google.com/group/softpub
 
  --
  Jack




 --
 Jack





 --
 Lift, the simply functional web framework http://liftweb.net
 Beginning Scala http://www.apress.com/book/view/1430219890
 Follow me: http://twitter.com/dpp
 Surf the harmonics






 --
 Jack

 



-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: execute code when browser is closed

2009-10-05 Thread Jack Widman
In my app, when the user is done searching on one keyword, they click a link
which takes them back to the main search page. Thats the time when I wanted
the CometActor to stop. Otherwise there will be too many threads floating
around and performance will suffer.

On Mon, Oct 5, 2009 at 2:50 PM, David Pollak
feeder.of.the.be...@gmail.comwrote:



 On Mon, Oct 5, 2009 at 11:45 AM, Jack Widman jack.wid...@gmail.comwrote:

 Interesting. I will try that. And I won't send any more ShutDownMessages
 :)
 Though I should add that each CometActor is doing a lot of processing. So
 I it would be good if I could shut one down somehow when the user searches
 on a new term. Timeout won't work because there is no way to know how long
 it will take.

 Maybe I could just kill all the actors directly that are doing the
 processing.


 That's going to be even worse.  You'll kill something out from under
 Lift... it's going to cause a huge pile of pain.

 You can remove an Actor from the session and that will cause ShutDown to be
 sent to it, but depending on how the Actor was written it's not going to
 stop processing its mailbox.

 Bottom line... there's no way to tell if a user is not looking at a page
 with an Actor anymore.  The best way to deal with that is timing the Actor
 out.  It's going to take time (your timeout period), but it's the best way
 to do it.



 On Mon, Oct 5, 2009 at 2:40 PM, David Pollak 
 feeder.of.the.be...@gmail.com wrote:



 On Mon, Oct 5, 2009 at 10:27 AM, Jack Widman jack.wid...@gmail.comwrote:

 Understood. My intention is to send a ShutDown message to the CometActor
 when somebody closes the browser. I need this so that when they visit the
 page in a browser again, the CometActor is 'reset'.


 First, there's no way to determine if the browser window is closed.

 Second, *DO NOT* send a ShutDown message to the CometActor.  This is an
 internal Lift piece of housekeeping.  If you do this, you will break stuff.
  Don't do it.  (There is a reason the message is not private, but it should
 not be used for this purpose.)

 CometActors can be named:

 lift:comet type=Search name={searchString}/

 You can then have a separate CometActor for each searchString.  Voila...
 you get what you want.  Now, how do you make then CometActor go away when
 it's not being used anymore?

 In your CometActor:
  override def lifespan: Box[TimeSpan] = Full(3 minutes)

 That means if a CometActor does not appear on a page for 3 minutes, it's
 removed from the session.  If the named CometActor is requested again, a new
 one will be created.




 On Mon, Oct 5, 2009 at 1:18 PM, marius d. marius.dan...@gmail.comwrote:


 HTTP session termination does not equate with browser-close event.

 Br's,
 Marius

 On Oct 5, 3:22 pm, Jack Widman jack.wid...@gmail.com wrote:
  Yes, thats what I meant. Thanks
 
  On Mon, Oct 5, 2009 at 4:10 AM, Timothy Perrett
 timo...@getintheloop.euwrote:
 
 
 
 
 
   But you can do it on session termination (which is what you
 probably
   want):
 
  
 http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scalado.
 ..
 
   Checkout the method:
 
   registerCleanupFunc
 
   Cheers, Tim
 
   On Oct 5, 8:54 am, Viktor Klang viktor.kl...@gmail.com wrote:
On Mon, Oct 5, 2009 at 6:50 AM, jack jack.wid...@gmail.com
 wrote:
 
 I would like to call a function when the browser is closed. How
 do I
 do this?
 
You cannot reliably do this.
 
--
Viktor Klang
 
Blog: klangism.blogspot.com
Twttr: viktorklang
 
Lift Committer - liftweb.com
AKKA Committer - akkasource.org
Cassidy - github.com/viktorklang/Cassidy.git
SoftPub founder:http://groups.google.com/group/softpub
 
  --
  Jack




 --
 Jack





 --
 Lift, the simply functional web framework http://liftweb.net
 Beginning Scala http://www.apress.com/book/view/1430219890
 Follow me: http://twitter.com/dpp
 Surf the harmonics






 --
 Jack





 --
 Lift, the simply functional web framework http://liftweb.net
 Beginning Scala http://www.apress.com/book/view/1430219890
 Follow me: http://twitter.com/dpp
 Surf the harmonics

 



-- 
Jack

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: execute code when browser is closed

2009-10-05 Thread David Pollak
On Mon, Oct 5, 2009 at 11:53 AM, Jack Widman jack.wid...@gmail.com wrote:

 In my app, when the user is done searching on one keyword, they click a
 link which takes them back to the main search page. Thats the time when I
 wanted the CometActor to stop. Otherwise there will be too many threads
 floating around and performance will suffer.


Why?  Actors do not consume threads, they consume memory unless they are
actively processing a message.




 On Mon, Oct 5, 2009 at 2:50 PM, David Pollak 
 feeder.of.the.be...@gmail.com wrote:



 On Mon, Oct 5, 2009 at 11:45 AM, Jack Widman jack.wid...@gmail.comwrote:

 Interesting. I will try that. And I won't send any more ShutDownMessages
 :)
 Though I should add that each CometActor is doing a lot of processing. So
 I it would be good if I could shut one down somehow when the user searches
 on a new term. Timeout won't work because there is no way to know how long
 it will take.

 Maybe I could just kill all the actors directly that are doing the
 processing.


 That's going to be even worse.  You'll kill something out from under
 Lift... it's going to cause a huge pile of pain.

 You can remove an Actor from the session and that will cause ShutDown to
 be sent to it, but depending on how the Actor was written it's not going to
 stop processing its mailbox.

 Bottom line... there's no way to tell if a user is not looking at a page
 with an Actor anymore.  The best way to deal with that is timing the Actor
 out.  It's going to take time (your timeout period), but it's the best way
 to do it.



 On Mon, Oct 5, 2009 at 2:40 PM, David Pollak 
 feeder.of.the.be...@gmail.com wrote:



 On Mon, Oct 5, 2009 at 10:27 AM, Jack Widman jack.wid...@gmail.comwrote:

 Understood. My intention is to send a ShutDown message to the
 CometActor when somebody closes the browser. I need this so that when they
 visit the page in a browser again, the CometActor is 'reset'.


 First, there's no way to determine if the browser window is closed.

 Second, *DO NOT* send a ShutDown message to the CometActor.  This is an
 internal Lift piece of housekeeping.  If you do this, you will break stuff.
  Don't do it.  (There is a reason the message is not private, but it should
 not be used for this purpose.)

 CometActors can be named:

 lift:comet type=Search name={searchString}/

 You can then have a separate CometActor for each searchString.  Voila...
 you get what you want.  Now, how do you make then CometActor go away when
 it's not being used anymore?

 In your CometActor:
  override def lifespan: Box[TimeSpan] = Full(3 minutes)

 That means if a CometActor does not appear on a page for 3 minutes, it's
 removed from the session.  If the named CometActor is requested again, a 
 new
 one will be created.




 On Mon, Oct 5, 2009 at 1:18 PM, marius d. marius.dan...@gmail.comwrote:


 HTTP session termination does not equate with browser-close event.

 Br's,
 Marius

 On Oct 5, 3:22 pm, Jack Widman jack.wid...@gmail.com wrote:
  Yes, thats what I meant. Thanks
 
  On Mon, Oct 5, 2009 at 4:10 AM, Timothy Perrett
 timo...@getintheloop.euwrote:
 
 
 
 
 
   But you can do it on session termination (which is what you
 probably
   want):
 
  
 http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scalado.
 ..
 
   Checkout the method:
 
   registerCleanupFunc
 
   Cheers, Tim
 
   On Oct 5, 8:54 am, Viktor Klang viktor.kl...@gmail.com wrote:
On Mon, Oct 5, 2009 at 6:50 AM, jack jack.wid...@gmail.com
 wrote:
 
 I would like to call a function when the browser is closed.
 How do I
 do this?
 
You cannot reliably do this.
 
--
Viktor Klang
 
Blog: klangism.blogspot.com
Twttr: viktorklang
 
Lift Committer - liftweb.com
AKKA Committer - akkasource.org
Cassidy - github.com/viktorklang/Cassidy.git
SoftPub founder:http://groups.google.com/group/softpub
 
  --
  Jack




 --
 Jack





 --
 Lift, the simply functional web framework http://liftweb.net
 Beginning Scala http://www.apress.com/book/view/1430219890
 Follow me: http://twitter.com/dpp
 Surf the harmonics






 --
 Jack





 --
 Lift, the simply functional web framework http://liftweb.net
 Beginning Scala http://www.apress.com/book/view/1430219890
 Follow me: http://twitter.com/dpp
 Surf the harmonics





 --
 Jack

 



-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: execute code when browser is closed

2009-10-05 Thread Jack Widman
Because when the users searches on a new keyword, the actors that were
processing the results for the last keyword are still processing (some of
them). But I can just send each of those a message to stop processing,  no?
No problem with that, right?

On Mon, Oct 5, 2009 at 3:02 PM, David Pollak
feeder.of.the.be...@gmail.comwrote:



 On Mon, Oct 5, 2009 at 11:53 AM, Jack Widman jack.wid...@gmail.comwrote:

 In my app, when the user is done searching on one keyword, they click a
 link which takes them back to the main search page. Thats the time when I
 wanted the CometActor to stop. Otherwise there will be too many threads
 floating around and performance will suffer.


 Why?  Actors do not consume threads, they consume memory unless they are
 actively processing a message.




 On Mon, Oct 5, 2009 at 2:50 PM, David Pollak 
 feeder.of.the.be...@gmail.com wrote:



 On Mon, Oct 5, 2009 at 11:45 AM, Jack Widman jack.wid...@gmail.comwrote:

 Interesting. I will try that. And I won't send any more ShutDownMessages
 :)
 Though I should add that each CometActor is doing a lot of processing.
 So I it would be good if I could shut one down somehow when the user
 searches on a new term. Timeout won't work because there is no way to know
 how long it will take.

 Maybe I could just kill all the actors directly that are doing the
 processing.


 That's going to be even worse.  You'll kill something out from under
 Lift... it's going to cause a huge pile of pain.

 You can remove an Actor from the session and that will cause ShutDown to
 be sent to it, but depending on how the Actor was written it's not going to
 stop processing its mailbox.

 Bottom line... there's no way to tell if a user is not looking at a page
 with an Actor anymore.  The best way to deal with that is timing the Actor
 out.  It's going to take time (your timeout period), but it's the best way
 to do it.



 On Mon, Oct 5, 2009 at 2:40 PM, David Pollak 
 feeder.of.the.be...@gmail.com wrote:



 On Mon, Oct 5, 2009 at 10:27 AM, Jack Widman jack.wid...@gmail.comwrote:

 Understood. My intention is to send a ShutDown message to the
 CometActor when somebody closes the browser. I need this so that when 
 they
 visit the page in a browser again, the CometActor is 'reset'.


 First, there's no way to determine if the browser window is closed.

 Second, *DO NOT* send a ShutDown message to the CometActor.  This is an
 internal Lift piece of housekeeping.  If you do this, you will break 
 stuff.
  Don't do it.  (There is a reason the message is not private, but it 
 should
 not be used for this purpose.)

 CometActors can be named:

 lift:comet type=Search name={searchString}/

 You can then have a separate CometActor for each searchString.
  Voila... you get what you want.  Now, how do you make then CometActor go
 away when it's not being used anymore?

 In your CometActor:
  override def lifespan: Box[TimeSpan] = Full(3 minutes)

 That means if a CometActor does not appear on a page for 3 minutes,
 it's removed from the session.  If the named CometActor is requested 
 again,
 a new one will be created.




 On Mon, Oct 5, 2009 at 1:18 PM, marius d. marius.dan...@gmail.comwrote:


 HTTP session termination does not equate with browser-close event.

 Br's,
 Marius

 On Oct 5, 3:22 pm, Jack Widman jack.wid...@gmail.com wrote:
  Yes, thats what I meant. Thanks
 
  On Mon, Oct 5, 2009 at 4:10 AM, Timothy Perrett
 timo...@getintheloop.euwrote:
 
 
 
 
 
   But you can do it on session termination (which is what you
 probably
   want):
 
  
 http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scalado.
 ..
 
   Checkout the method:
 
   registerCleanupFunc
 
   Cheers, Tim
 
   On Oct 5, 8:54 am, Viktor Klang viktor.kl...@gmail.com wrote:
On Mon, Oct 5, 2009 at 6:50 AM, jack jack.wid...@gmail.com
 wrote:
 
 I would like to call a function when the browser is closed.
 How do I
 do this?
 
You cannot reliably do this.
 
--
Viktor Klang
 
Blog: klangism.blogspot.com
Twttr: viktorklang
 
Lift Committer - liftweb.com
AKKA Committer - akkasource.org
Cassidy - github.com/viktorklang/Cassidy.git
SoftPub founder:http://groups.google.com/group/softpub
 
  --
  Jack




 --
 Jack





 --
 Lift, the simply functional web framework http://liftweb.net
 Beginning Scala http://www.apress.com/book/view/1430219890
 Follow me: http://twitter.com/dpp
 Surf the harmonics






 --
 Jack





 --
 Lift, the simply functional web framework http://liftweb.net
 Beginning Scala http://www.apress.com/book/view/1430219890
 Follow me: http://twitter.com/dpp
 Surf the harmonics





 --
 Jack





 --
 Lift, the simply functional web framework http://liftweb.net
 Beginning Scala http://www.apress.com/book/view/1430219890
 Follow me: http://twitter.com/dpp
 Surf the harmonics

 



-- 
Jack

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To 

[Lift] Re: execute code when browser is closed

2009-10-05 Thread David Pollak
On Mon, Oct 5, 2009 at 12:06 PM, Jack Widman jack.wid...@gmail.com wrote:

 Because when the users searches on a new keyword, the actors that were
 processing the results for the last keyword are still processing (some of
 them). But I can just send each of those a message to stop processing,  no?
 No problem with that, right?


Sure... send them a message that says tell all your jobs to stop.  This
has nothing to do with the CometActor lifecycle.  It is all your application
level stuff.




 On Mon, Oct 5, 2009 at 3:02 PM, David Pollak 
 feeder.of.the.be...@gmail.com wrote:



 On Mon, Oct 5, 2009 at 11:53 AM, Jack Widman jack.wid...@gmail.comwrote:

 In my app, when the user is done searching on one keyword, they click a
 link which takes them back to the main search page. Thats the time when I
 wanted the CometActor to stop. Otherwise there will be too many threads
 floating around and performance will suffer.


 Why?  Actors do not consume threads, they consume memory unless they are
 actively processing a message.




 On Mon, Oct 5, 2009 at 2:50 PM, David Pollak 
 feeder.of.the.be...@gmail.com wrote:



 On Mon, Oct 5, 2009 at 11:45 AM, Jack Widman jack.wid...@gmail.comwrote:

 Interesting. I will try that. And I won't send any more
 ShutDownMessages :)
 Though I should add that each CometActor is doing a lot of processing.
 So I it would be good if I could shut one down somehow when the user
 searches on a new term. Timeout won't work because there is no way to know
 how long it will take.

 Maybe I could just kill all the actors directly that are doing the
 processing.


 That's going to be even worse.  You'll kill something out from under
 Lift... it's going to cause a huge pile of pain.

 You can remove an Actor from the session and that will cause ShutDown to
 be sent to it, but depending on how the Actor was written it's not going to
 stop processing its mailbox.

 Bottom line... there's no way to tell if a user is not looking at a page
 with an Actor anymore.  The best way to deal with that is timing the Actor
 out.  It's going to take time (your timeout period), but it's the best way
 to do it.



 On Mon, Oct 5, 2009 at 2:40 PM, David Pollak 
 feeder.of.the.be...@gmail.com wrote:



 On Mon, Oct 5, 2009 at 10:27 AM, Jack Widman 
 jack.wid...@gmail.comwrote:

 Understood. My intention is to send a ShutDown message to the
 CometActor when somebody closes the browser. I need this so that when 
 they
 visit the page in a browser again, the CometActor is 'reset'.


 First, there's no way to determine if the browser window is closed.

 Second, *DO NOT* send a ShutDown message to the CometActor.  This is
 an internal Lift piece of housekeeping.  If you do this, you will break
 stuff.  Don't do it.  (There is a reason the message is not private, but 
 it
 should not be used for this purpose.)

 CometActors can be named:

 lift:comet type=Search name={searchString}/

 You can then have a separate CometActor for each searchString.
  Voila... you get what you want.  Now, how do you make then CometActor go
 away when it's not being used anymore?

 In your CometActor:
  override def lifespan: Box[TimeSpan] = Full(3 minutes)

 That means if a CometActor does not appear on a page for 3 minutes,
 it's removed from the session.  If the named CometActor is requested 
 again,
 a new one will be created.




 On Mon, Oct 5, 2009 at 1:18 PM, marius d. 
 marius.dan...@gmail.comwrote:


 HTTP session termination does not equate with browser-close event.

 Br's,
 Marius

 On Oct 5, 3:22 pm, Jack Widman jack.wid...@gmail.com wrote:
  Yes, thats what I meant. Thanks
 
  On Mon, Oct 5, 2009 at 4:10 AM, Timothy Perrett
 timo...@getintheloop.euwrote:
 
 
 
 
 
   But you can do it on session termination (which is what you
 probably
   want):
 
  
 http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scalado.
 ..
 
   Checkout the method:
 
   registerCleanupFunc
 
   Cheers, Tim
 
   On Oct 5, 8:54 am, Viktor Klang viktor.kl...@gmail.com wrote:
On Mon, Oct 5, 2009 at 6:50 AM, jack jack.wid...@gmail.com
 wrote:
 
 I would like to call a function when the browser is closed.
 How do I
 do this?
 
You cannot reliably do this.
 
--
Viktor Klang
 
Blog: klangism.blogspot.com
Twttr: viktorklang
 
Lift Committer - liftweb.com
AKKA Committer - akkasource.org
Cassidy - github.com/viktorklang/Cassidy.git
SoftPub founder:http://groups.google.com/group/softpub
 
  --
  Jack




 --
 Jack





 --
 Lift, the simply functional web framework http://liftweb.net
 Beginning Scala http://www.apress.com/book/view/1430219890
 Follow me: http://twitter.com/dpp
 Surf the harmonics






 --
 Jack





 --
 Lift, the simply functional web framework http://liftweb.net
 Beginning Scala http://www.apress.com/book/view/1430219890
 Follow me: http://twitter.com/dpp
 Surf the harmonics





 --
 Jack





 --
 Lift, the simply functional web framework http://liftweb.net
 Beginning Scala 

[Lift] Re: execute code when browser is closed

2009-10-05 Thread Jack Widman
Good. Only thing is that if their job was to start an actor to go out and
search some pages, say, then 'stop your job' means '   'call your 'exit'
method, no?Not trying to be a wise guy. I actually have a number of VCs
lined up to look at my app. Overall I am very glad to be using Lift. On the
Comet alone it save me a LOT of time.
Of course, I  have a lot to learn.

On Mon, Oct 5, 2009 at 3:08 PM, David Pollak
feeder.of.the.be...@gmail.comwrote:



 On Mon, Oct 5, 2009 at 12:06 PM, Jack Widman jack.wid...@gmail.comwrote:

 Because when the users searches on a new keyword, the actors that were
 processing the results for the last keyword are still processing (some of
 them). But I can just send each of those a message to stop processing,  no?
 No problem with that, right?


 Sure... send them a message that says tell all your jobs to stop.  This
 has nothing to do with the CometActor lifecycle.  It is all your application
 level stuff.




 On Mon, Oct 5, 2009 at 3:02 PM, David Pollak 
 feeder.of.the.be...@gmail.com wrote:



 On Mon, Oct 5, 2009 at 11:53 AM, Jack Widman jack.wid...@gmail.comwrote:

 In my app, when the user is done searching on one keyword, they click a
 link which takes them back to the main search page. Thats the time when I
 wanted the CometActor to stop. Otherwise there will be too many threads
 floating around and performance will suffer.


 Why?  Actors do not consume threads, they consume memory unless they are
 actively processing a message.




 On Mon, Oct 5, 2009 at 2:50 PM, David Pollak 
 feeder.of.the.be...@gmail.com wrote:



 On Mon, Oct 5, 2009 at 11:45 AM, Jack Widman jack.wid...@gmail.comwrote:

 Interesting. I will try that. And I won't send any more
 ShutDownMessages :)
 Though I should add that each CometActor is doing a lot of processing.
 So I it would be good if I could shut one down somehow when the user
 searches on a new term. Timeout won't work because there is no way to 
 know
 how long it will take.

 Maybe I could just kill all the actors directly that are doing the
 processing.


 That's going to be even worse.  You'll kill something out from under
 Lift... it's going to cause a huge pile of pain.

 You can remove an Actor from the session and that will cause ShutDown
 to be sent to it, but depending on how the Actor was written it's not 
 going
 to stop processing its mailbox.

 Bottom line... there's no way to tell if a user is not looking at a
 page with an Actor anymore.  The best way to deal with that is timing the
 Actor out.  It's going to take time (your timeout period), but it's the 
 best
 way to do it.



 On Mon, Oct 5, 2009 at 2:40 PM, David Pollak 
 feeder.of.the.be...@gmail.com wrote:



 On Mon, Oct 5, 2009 at 10:27 AM, Jack Widman 
 jack.wid...@gmail.comwrote:

 Understood. My intention is to send a ShutDown message to the
 CometActor when somebody closes the browser. I need this so that when 
 they
 visit the page in a browser again, the CometActor is 'reset'.


 First, there's no way to determine if the browser window is closed.

 Second, *DO NOT* send a ShutDown message to the CometActor.  This is
 an internal Lift piece of housekeeping.  If you do this, you will break
 stuff.  Don't do it.  (There is a reason the message is not private, 
 but it
 should not be used for this purpose.)

 CometActors can be named:

 lift:comet type=Search name={searchString}/

 You can then have a separate CometActor for each searchString.
  Voila... you get what you want.  Now, how do you make then CometActor 
 go
 away when it's not being used anymore?

 In your CometActor:
  override def lifespan: Box[TimeSpan] = Full(3 minutes)

 That means if a CometActor does not appear on a page for 3 minutes,
 it's removed from the session.  If the named CometActor is requested 
 again,
 a new one will be created.




 On Mon, Oct 5, 2009 at 1:18 PM, marius d. 
 marius.dan...@gmail.comwrote:


 HTTP session termination does not equate with browser-close event.

 Br's,
 Marius

 On Oct 5, 3:22 pm, Jack Widman jack.wid...@gmail.com wrote:
  Yes, thats what I meant. Thanks
 
  On Mon, Oct 5, 2009 at 4:10 AM, Timothy Perrett
 timo...@getintheloop.euwrote:
 
 
 
 
 
   But you can do it on session termination (which is what you
 probably
   want):
 
  
 http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scalado.
 ..
 
   Checkout the method:
 
   registerCleanupFunc
 
   Cheers, Tim
 
   On Oct 5, 8:54 am, Viktor Klang viktor.kl...@gmail.com
 wrote:
On Mon, Oct 5, 2009 at 6:50 AM, jack jack.wid...@gmail.com
 wrote:
 
 I would like to call a function when the browser is closed.
 How do I
 do this?
 
You cannot reliably do this.
 
--
Viktor Klang
 
Blog: klangism.blogspot.com
Twttr: viktorklang
 
Lift Committer - liftweb.com
AKKA Committer - akkasource.org
Cassidy - github.com/viktorklang/Cassidy.git
SoftPub founder:http://groups.google.com/group/softpub
 
  --
  Jack




 --
 Jack





 --
 Lift, the simply 

[Lift] Re: execute code when browser is closed

2009-10-05 Thread David Pollak
On Mon, Oct 5, 2009 at 12:13 PM, Jack Widman jack.wid...@gmail.com wrote:

 Good. Only thing is that if their job was to start an actor to go out and
 search some pages, say, then 'stop your job' means '   'call your 'exit'
 method, no?


I have no idea what you application logic looks like, so I don't know what
call your exit will do.  If you call exit on a CometActor, you'll mess
things up (as you've discovered.)  But your search shouldn't be taking place
in the CometActor.  Your search should be taking place on other
threads/actors which then report their status back to the CometActor.


 Not trying to be a wise guy. I actually have a number of VCs lined up to
 look at my app. Overall I am very glad to be using Lift. On the Comet alone
 it save me a LOT of time.
 Of course, I  have a lot to learn.


 On Mon, Oct 5, 2009 at 3:08 PM, David Pollak 
 feeder.of.the.be...@gmail.com wrote:



 On Mon, Oct 5, 2009 at 12:06 PM, Jack Widman jack.wid...@gmail.comwrote:

 Because when the users searches on a new keyword, the actors that were
 processing the results for the last keyword are still processing (some of
 them). But I can just send each of those a message to stop processing,  no?
 No problem with that, right?


 Sure... send them a message that says tell all your jobs to stop.  This
 has nothing to do with the CometActor lifecycle.  It is all your application
 level stuff.




 On Mon, Oct 5, 2009 at 3:02 PM, David Pollak 
 feeder.of.the.be...@gmail.com wrote:



 On Mon, Oct 5, 2009 at 11:53 AM, Jack Widman jack.wid...@gmail.comwrote:

 In my app, when the user is done searching on one keyword, they click a
 link which takes them back to the main search page. Thats the time when I
 wanted the CometActor to stop. Otherwise there will be too many threads
 floating around and performance will suffer.


 Why?  Actors do not consume threads, they consume memory unless they are
 actively processing a message.




 On Mon, Oct 5, 2009 at 2:50 PM, David Pollak 
 feeder.of.the.be...@gmail.com wrote:



 On Mon, Oct 5, 2009 at 11:45 AM, Jack Widman 
 jack.wid...@gmail.comwrote:

 Interesting. I will try that. And I won't send any more
 ShutDownMessages :)
 Though I should add that each CometActor is doing a lot of
 processing. So I it would be good if I could shut one down somehow when 
 the
 user searches on a new term. Timeout won't work because there is no way 
 to
 know how long it will take.

 Maybe I could just kill all the actors directly that are doing the
 processing.


 That's going to be even worse.  You'll kill something out from under
 Lift... it's going to cause a huge pile of pain.

 You can remove an Actor from the session and that will cause ShutDown
 to be sent to it, but depending on how the Actor was written it's not 
 going
 to stop processing its mailbox.

 Bottom line... there's no way to tell if a user is not looking at a
 page with an Actor anymore.  The best way to deal with that is timing the
 Actor out.  It's going to take time (your timeout period), but it's the 
 best
 way to do it.



 On Mon, Oct 5, 2009 at 2:40 PM, David Pollak 
 feeder.of.the.be...@gmail.com wrote:



 On Mon, Oct 5, 2009 at 10:27 AM, Jack Widman jack.wid...@gmail.com
  wrote:

 Understood. My intention is to send a ShutDown message to the
 CometActor when somebody closes the browser. I need this so that when 
 they
 visit the page in a browser again, the CometActor is 'reset'.


 First, there's no way to determine if the browser window is closed.

 Second, *DO NOT* send a ShutDown message to the CometActor.  This is
 an internal Lift piece of housekeeping.  If you do this, you will break
 stuff.  Don't do it.  (There is a reason the message is not private, 
 but it
 should not be used for this purpose.)

 CometActors can be named:

 lift:comet type=Search name={searchString}/

 You can then have a separate CometActor for each searchString.
  Voila... you get what you want.  Now, how do you make then CometActor 
 go
 away when it's not being used anymore?

 In your CometActor:
  override def lifespan: Box[TimeSpan] = Full(3 minutes)

 That means if a CometActor does not appear on a page for 3 minutes,
 it's removed from the session.  If the named CometActor is requested 
 again,
 a new one will be created.




 On Mon, Oct 5, 2009 at 1:18 PM, marius d. marius.dan...@gmail.com
  wrote:


 HTTP session termination does not equate with browser-close event.

 Br's,
 Marius

 On Oct 5, 3:22 pm, Jack Widman jack.wid...@gmail.com wrote:
  Yes, thats what I meant. Thanks
 
  On Mon, Oct 5, 2009 at 4:10 AM, Timothy Perrett
 timo...@getintheloop.euwrote:
 
 
 
 
 
   But you can do it on session termination (which is what you
 probably
   want):
 
  
 http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scalado.
 ..
 
   Checkout the method:
 
   registerCleanupFunc
 
   Cheers, Tim
 
   On Oct 5, 8:54 am, Viktor Klang viktor.kl...@gmail.com
 wrote:
On Mon, Oct 5, 2009 at 6:50 AM, jack jack.wid...@gmail.com
 

[Lift] Re: execute code when browser is closed

2009-10-05 Thread Jack Widman
Sorry if this is a dumb question but in lift:comet type=Search
name={searchString}/, what is searchString? This is in an html file. I am
obviously missing something.

On Mon, Oct 5, 2009 at 2:40 PM, David Pollak
feeder.of.the.be...@gmail.comwrote:



 On Mon, Oct 5, 2009 at 10:27 AM, Jack Widman jack.wid...@gmail.comwrote:

 Understood. My intention is to send a ShutDown message to the CometActor
 when somebody closes the browser. I need this so that when they visit the
 page in a browser again, the CometActor is 'reset'.


 First, there's no way to determine if the browser window is closed.

 Second, *DO NOT* send a ShutDown message to the CometActor.  This is an
 internal Lift piece of housekeeping.  If you do this, you will break stuff.
  Don't do it.  (There is a reason the message is not private, but it should
 not be used for this purpose.)

 CometActors can be named:

 lift:comet type=Search name={searchString}/

 You can then have a separate CometActor for each searchString.  Voila...
 you get what you want.  Now, how do you make then CometActor go away when
 it's not being used anymore?

 In your CometActor:
  override def lifespan: Box[TimeSpan] = Full(3 minutes)

 That means if a CometActor does not appear on a page for 3 minutes, it's
 removed from the session.  If the named CometActor is requested again, a new
 one will be created.




 On Mon, Oct 5, 2009 at 1:18 PM, marius d. marius.dan...@gmail.comwrote:


 HTTP session termination does not equate with browser-close event.

 Br's,
 Marius

 On Oct 5, 3:22 pm, Jack Widman jack.wid...@gmail.com wrote:
  Yes, thats what I meant. Thanks
 
  On Mon, Oct 5, 2009 at 4:10 AM, Timothy Perrett
 timo...@getintheloop.euwrote:
 
 
 
 
 
   But you can do it on session termination (which is what you probably
   want):
 
  
 http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scalado...
 
   Checkout the method:
 
   registerCleanupFunc
 
   Cheers, Tim
 
   On Oct 5, 8:54 am, Viktor Klang viktor.kl...@gmail.com wrote:
On Mon, Oct 5, 2009 at 6:50 AM, jack jack.wid...@gmail.com
 wrote:
 
 I would like to call a function when the browser is closed. How
 do I
 do this?
 
You cannot reliably do this.
 
--
Viktor Klang
 
Blog: klangism.blogspot.com
Twttr: viktorklang
 
Lift Committer - liftweb.com
AKKA Committer - akkasource.org
Cassidy - github.com/viktorklang/Cassidy.git
SoftPub founder:http://groups.google.com/group/softpub
 
  --
  Jack




 --
 Jack





 --
 Lift, the simply functional web framework http://liftweb.net
 Beginning Scala http://www.apress.com/book/view/1430219890
 Follow me: http://twitter.com/dpp
 Surf the harmonics


 



-- 
Jack

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: execute code when browser is closed

2009-10-05 Thread jack

i guess you meant put the snippet right in the CometActor. Ok. Now I'm
getting it.

On Oct 5, 11:46 pm, Jack Widman jack.wid...@gmail.com wrote:
 Sorry if this is a dumb question but in lift:comet type=Search
 name={searchString}/, what is searchString? This is in an html file. I am
 obviously missing something.

 On Mon, Oct 5, 2009 at 2:40 PM, David Pollak
 feeder.of.the.be...@gmail.comwrote:







  On Mon, Oct 5, 2009 at 10:27 AM, Jack Widman jack.wid...@gmail.comwrote:

  Understood. My intention is to send a ShutDown message to the CometActor
  when somebody closes the browser. I need this so that when they visit the
  page in a browser again, the CometActor is 'reset'.

  First, there's no way to determine if the browser window is closed.

  Second, *DO NOT* send a ShutDown message to the CometActor.  This is an
  internal Lift piece of housekeeping.  If you do this, you will break stuff.
   Don't do it.  (There is a reason the message is not private, but it should
  not be used for this purpose.)

  CometActors can be named:

  lift:comet type=Search name={searchString}/

  You can then have a separate CometActor for each searchString.  Voila...
  you get what you want.  Now, how do you make then CometActor go away when
  it's not being used anymore?

  In your CometActor:
   override def lifespan: Box[TimeSpan] = Full(3 minutes)

  That means if a CometActor does not appear on a page for 3 minutes, it's
  removed from the session.  If the named CometActor is requested again, a new
  one will be created.

  On Mon, Oct 5, 2009 at 1:18 PM, marius d. marius.dan...@gmail.comwrote:

  HTTP session termination does not equate with browser-close event.

  Br's,
  Marius

  On Oct 5, 3:22 pm, Jack Widman jack.wid...@gmail.com wrote:
   Yes, thats what I meant. Thanks

   On Mon, Oct 5, 2009 at 4:10 AM, Timothy Perrett
  timo...@getintheloop.euwrote:

But you can do it on session termination (which is what you probably
want):

 http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scalado...

Checkout the method:

registerCleanupFunc

Cheers, Tim

On Oct 5, 8:54 am, Viktor Klang viktor.kl...@gmail.com wrote:
 On Mon, Oct 5, 2009 at 6:50 AM, jack jack.wid...@gmail.com
  wrote:

  I would like to call a function when the browser is closed. How
  do I
  do this?

 You cannot reliably do this.

 --
 Viktor Klang

 Blog: klangism.blogspot.com
 Twttr: viktorklang

 Lift Committer - liftweb.com
 AKKA Committer - akkasource.org
 Cassidy - github.com/viktorklang/Cassidy.git
 SoftPub founder:http://groups.google.com/group/softpub

   --
   Jack

  --
  Jack

  --
  Lift, the simply functional web frameworkhttp://liftweb.net
  Beginning Scalahttp://www.apress.com/book/view/1430219890
  Follow me:http://twitter.com/dpp
  Surf the harmonics

 --
 Jack
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: execute code when browser is closed

2009-10-05 Thread Naftoli Gugenheim

I guess you could generate the comet tag or attribute from a snippet...

-
Jack Widmanjack.wid...@gmail.com wrote:

Sorry if this is a dumb question but in lift:comet type=Search
name={searchString}/, what is searchString? This is in an html file. I am
obviously missing something.

On Mon, Oct 5, 2009 at 2:40 PM, David Pollak
feeder.of.the.be...@gmail.comwrote:



 On Mon, Oct 5, 2009 at 10:27 AM, Jack Widman jack.wid...@gmail.comwrote:

 Understood. My intention is to send a ShutDown message to the CometActor
 when somebody closes the browser. I need this so that when they visit the
 page in a browser again, the CometActor is 'reset'.


 First, there's no way to determine if the browser window is closed.

 Second, *DO NOT* send a ShutDown message to the CometActor.  This is an
 internal Lift piece of housekeeping.  If you do this, you will break stuff.
  Don't do it.  (There is a reason the message is not private, but it should
 not be used for this purpose.)

 CometActors can be named:

 lift:comet type=Search name={searchString}/

 You can then have a separate CometActor for each searchString.  Voila...
 you get what you want.  Now, how do you make then CometActor go away when
 it's not being used anymore?

 In your CometActor:
  override def lifespan: Box[TimeSpan] = Full(3 minutes)

 That means if a CometActor does not appear on a page for 3 minutes, it's
 removed from the session.  If the named CometActor is requested again, a new
 one will be created.




 On Mon, Oct 5, 2009 at 1:18 PM, marius d. marius.dan...@gmail.comwrote:


 HTTP session termination does not equate with browser-close event.

 Br's,
 Marius

 On Oct 5, 3:22 pm, Jack Widman jack.wid...@gmail.com wrote:
  Yes, thats what I meant. Thanks
 
  On Mon, Oct 5, 2009 at 4:10 AM, Timothy Perrett
 timo...@getintheloop.euwrote:
 
 
 
 
 
   But you can do it on session termination (which is what you probably
   want):
 
  
 http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scalado...
 
   Checkout the method:
 
   registerCleanupFunc
 
   Cheers, Tim
 
   On Oct 5, 8:54 am, Viktor Klang viktor.kl...@gmail.com wrote:
On Mon, Oct 5, 2009 at 6:50 AM, jack jack.wid...@gmail.com
 wrote:
 
 I would like to call a function when the browser is closed. How
 do I
 do this?
 
You cannot reliably do this.
 
--
Viktor Klang
 
Blog: klangism.blogspot.com
Twttr: viktorklang
 
Lift Committer - liftweb.com
AKKA Committer - akkasource.org
Cassidy - github.com/viktorklang/Cassidy.git
SoftPub founder:http://groups.google.com/group/softpub
 
  --
  Jack




 --
 Jack





 --
 Lift, the simply functional web framework http://liftweb.net
 Beginning Scala http://www.apress.com/book/view/1430219890
 Follow me: http://twitter.com/dpp
 Surf the harmonics


 



-- 
Jack



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: execute code when browser is closed

2009-10-05 Thread Naftoli Gugenheim

What do you mean?

-
jackjack.wid...@gmail.com wrote:


i guess you meant put the snippet right in the CometActor. Ok. Now I'm
getting it.

On Oct 5, 11:46 pm, Jack Widman jack.wid...@gmail.com wrote:
 Sorry if this is a dumb question but in lift:comet type=Search
 name={searchString}/, what is searchString? This is in an html file. I am
 obviously missing something.

 On Mon, Oct 5, 2009 at 2:40 PM, David Pollak
 feeder.of.the.be...@gmail.comwrote:







  On Mon, Oct 5, 2009 at 10:27 AM, Jack Widman jack.wid...@gmail.comwrote:

  Understood. My intention is to send a ShutDown message to the CometActor
  when somebody closes the browser. I need this so that when they visit the
  page in a browser again, the CometActor is 'reset'.

  First, there's no way to determine if the browser window is closed.

  Second, *DO NOT* send a ShutDown message to the CometActor.  This is an
  internal Lift piece of housekeeping.  If you do this, you will break stuff.
   Don't do it.  (There is a reason the message is not private, but it should
  not be used for this purpose.)

  CometActors can be named:

  lift:comet type=Search name={searchString}/

  You can then have a separate CometActor for each searchString.  Voila...
  you get what you want.  Now, how do you make then CometActor go away when
  it's not being used anymore?

  In your CometActor:
   override def lifespan: Box[TimeSpan] = Full(3 minutes)

  That means if a CometActor does not appear on a page for 3 minutes, it's
  removed from the session.  If the named CometActor is requested again, a new
  one will be created.

  On Mon, Oct 5, 2009 at 1:18 PM, marius d. marius.dan...@gmail.comwrote:

  HTTP session termination does not equate with browser-close event.

  Br's,
  Marius

  On Oct 5, 3:22 pm, Jack Widman jack.wid...@gmail.com wrote:
   Yes, thats what I meant. Thanks

   On Mon, Oct 5, 2009 at 4:10 AM, Timothy Perrett
  timo...@getintheloop.euwrote:

But you can do it on session termination (which is what you probably
want):

 http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scalado...

Checkout the method:

registerCleanupFunc

Cheers, Tim

On Oct 5, 8:54 am, Viktor Klang viktor.kl...@gmail.com wrote:
 On Mon, Oct 5, 2009 at 6:50 AM, jack jack.wid...@gmail.com
  wrote:

  I would like to call a function when the browser is closed. How
  do I
  do this?

 You cannot reliably do this.

 --
 Viktor Klang

 Blog: klangism.blogspot.com
 Twttr: viktorklang

 Lift Committer - liftweb.com
 AKKA Committer - akkasource.org
 Cassidy - github.com/viktorklang/Cassidy.git
 SoftPub founder:http://groups.google.com/group/softpub

   --
   Jack

  --
  Jack

  --
  Lift, the simply functional web frameworkhttp://liftweb.net
  Beginning Scalahttp://www.apress.com/book/view/1430219890
  Follow me:http://twitter.com/dpp
  Surf the harmonics

 --
 Jack


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: execute code when browser is closed

2009-10-05 Thread jack

Let me start again. Maybe I am misunderstanding when Comet should be
used. In my application, people search for web pages. I do a lot of
processing for each resulting page. First I just display the links and
then as the processing is finished, the links on the page are
automatically modified with the data I just found for each link. This
is all working fine.

But, the session is being shared among all users so if I make one
search in one browser, and then make another search from another
browser, I get the results from the first browser.

David suggested I name each CometActor differently. That is not
working, though maybe I am not doing it right.

On Oct 6, 12:01 am, Naftoli Gugenheim naftoli...@gmail.com wrote:
 What do you mean?

 -

 jackjack.wid...@gmail.com wrote:

 i guess you meant put the snippet right in the CometActor. Ok. Now I'm
 getting it.

 On Oct 5, 11:46 pm, Jack Widman jack.wid...@gmail.com wrote:



  Sorry if this is a dumb question but in lift:comet type=Search
  name={searchString}/, what is searchString? This is in an html file. I am
  obviously missing something.

  On Mon, Oct 5, 2009 at 2:40 PM, David Pollak
  feeder.of.the.be...@gmail.comwrote:

   On Mon, Oct 5, 2009 at 10:27 AM, Jack Widman jack.wid...@gmail.comwrote:

   Understood. My intention is to send a ShutDown message to the CometActor
   when somebody closes the browser. I need this so that when they visit the
   page in a browser again, the CometActor is 'reset'.

   First, there's no way to determine if the browser window is closed.

   Second, *DO NOT* send a ShutDown message to the CometActor.  This is an
   internal Lift piece of housekeeping.  If you do this, you will break 
   stuff.
    Don't do it.  (There is a reason the message is not private, but it 
   should
   not be used for this purpose.)

   CometActors can be named:

   lift:comet type=Search name={searchString}/

   You can then have a separate CometActor for each searchString.  Voila...
   you get what you want.  Now, how do you make then CometActor go away when
   it's not being used anymore?

   In your CometActor:
    override def lifespan: Box[TimeSpan] = Full(3 minutes)

   That means if a CometActor does not appear on a page for 3 minutes, it's
   removed from the session.  If the named CometActor is requested again, a 
   new
   one will be created.

   On Mon, Oct 5, 2009 at 1:18 PM, marius d. marius.dan...@gmail.comwrote:

   HTTP session termination does not equate with browser-close event.

   Br's,
   Marius

   On Oct 5, 3:22 pm, Jack Widman jack.wid...@gmail.com wrote:
Yes, thats what I meant. Thanks

On Mon, Oct 5, 2009 at 4:10 AM, Timothy Perrett
   timo...@getintheloop.euwrote:

 But you can do it on session termination (which is what you probably
 want):

  http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scalado...

 Checkout the method:

 registerCleanupFunc

 Cheers, Tim

 On Oct 5, 8:54 am, Viktor Klang viktor.kl...@gmail.com wrote:
  On Mon, Oct 5, 2009 at 6:50 AM, jack jack.wid...@gmail.com
   wrote:

   I would like to call a function when the browser is closed. How
   do I
   do this?

  You cannot reliably do this.

  --
  Viktor Klang

  Blog: klangism.blogspot.com
  Twttr: viktorklang

  Lift Committer - liftweb.com
  AKKA Committer - akkasource.org
  Cassidy - github.com/viktorklang/Cassidy.git
  SoftPub founder:http://groups.google.com/group/softpub

--
Jack

   --
   Jack

   --
   Lift, the simply functional web frameworkhttp://liftweb.net
   Beginning Scalahttp://www.apress.com/book/view/1430219890
   Follow me:http://twitter.com/dpp
   Surf the harmonics

  --
  Jack
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: execute code when browser is closed

2009-10-05 Thread Naftoli Gugenheim

You are correct that Comet is a way to update information after the page is 
loaded. I think there's a simpler way using ajax, but I haven't explored those 
areas of Lift yet. But meanwhile you need to have the xml specifying the comet 
actor be dynamic. So you need to have that xml be generated by a snippet. A 
snippet is an XML to XML function.


-
jackjack.wid...@gmail.com wrote:


Let me start again. Maybe I am misunderstanding when Comet should be
used. In my application, people search for web pages. I do a lot of
processing for each resulting page. First I just display the links and
then as the processing is finished, the links on the page are
automatically modified with the data I just found for each link. This
is all working fine.

But, the session is being shared among all users so if I make one
search in one browser, and then make another search from another
browser, I get the results from the first browser.

David suggested I name each CometActor differently. That is not
working, though maybe I am not doing it right.

On Oct 6, 12:01 am, Naftoli Gugenheim naftoli...@gmail.com wrote:
 What do you mean?

 -

 jackjack.wid...@gmail.com wrote:

 i guess you meant put the snippet right in the CometActor. Ok. Now I'm
 getting it.

 On Oct 5, 11:46 pm, Jack Widman jack.wid...@gmail.com wrote:



  Sorry if this is a dumb question but in lift:comet type=Search
  name={searchString}/, what is searchString? This is in an html file. I am
  obviously missing something.

  On Mon, Oct 5, 2009 at 2:40 PM, David Pollak
  feeder.of.the.be...@gmail.comwrote:

   On Mon, Oct 5, 2009 at 10:27 AM, Jack Widman jack.wid...@gmail.comwrote:

   Understood. My intention is to send a ShutDown message to the CometActor
   when somebody closes the browser. I need this so that when they visit the
   page in a browser again, the CometActor is 'reset'.

   First, there's no way to determine if the browser window is closed.

   Second, *DO NOT* send a ShutDown message to the CometActor.  This is an
   internal Lift piece of housekeeping.  If you do this, you will break 
   stuff.
    Don't do it.  (There is a reason the message is not private, but it 
   should
   not be used for this purpose.)

   CometActors can be named:

   lift:comet type=Search name={searchString}/

   You can then have a separate CometActor for each searchString.  Voila...
   you get what you want.  Now, how do you make then CometActor go away when
   it's not being used anymore?

   In your CometActor:
    override def lifespan: Box[TimeSpan] = Full(3 minutes)

   That means if a CometActor does not appear on a page for 3 minutes, it's
   removed from the session.  If the named CometActor is requested again, a 
   new
   one will be created.

   On Mon, Oct 5, 2009 at 1:18 PM, marius d. marius.dan...@gmail.comwrote:

   HTTP session termination does not equate with browser-close event.

   Br's,
   Marius

   On Oct 5, 3:22 pm, Jack Widman jack.wid...@gmail.com wrote:
Yes, thats what I meant. Thanks

On Mon, Oct 5, 2009 at 4:10 AM, Timothy Perrett
   timo...@getintheloop.euwrote:

 But you can do it on session termination (which is what you probably
 want):

  http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scalado...

 Checkout the method:

 registerCleanupFunc

 Cheers, Tim

 On Oct 5, 8:54 am, Viktor Klang viktor.kl...@gmail.com wrote:
  On Mon, Oct 5, 2009 at 6:50 AM, jack jack.wid...@gmail.com
   wrote:

   I would like to call a function when the browser is closed. How
   do I
   do this?

  You cannot reliably do this.

  --
  Viktor Klang

  Blog: klangism.blogspot.com
  Twttr: viktorklang

  Lift Committer - liftweb.com
  AKKA Committer - akkasource.org
  Cassidy - github.com/viktorklang/Cassidy.git
  SoftPub founder:http://groups.google.com/group/softpub

--
Jack

   --
   Jack

   --
   Lift, the simply functional web frameworkhttp://liftweb.net
   Beginning Scalahttp://www.apress.com/book/view/1430219890
   Follow me:http://twitter.com/dpp
   Surf the harmonics

  --
  Jack


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: execute code when browser is closed

2009-10-05 Thread Jack Widman
So I am using a snippet like this
 def go:NodeSeq = {
var term:String = S.param(term).openOr()
lift:surround with=default at=content
lift:comet type=JoopComet name={term}
auth:joop/auth:joop
/lift:comet
/lift:surround
  }

And the term is indeed different each time. But I am still getting the same
results from two different browsers with different terms.

On Tue, Oct 6, 2009 at 12:18 AM, Naftoli Gugenheim naftoli...@gmail.comwrote:


 You are correct that Comet is a way to update information after the page is
 loaded. I think there's a simpler way using ajax, but I haven't explored
 those areas of Lift yet. But meanwhile you need to have the xml specifying
 the comet actor be dynamic. So you need to have that xml be generated by a
 snippet. A snippet is an XML to XML function.


 -
 jackjack.wid...@gmail.com wrote:


 Let me start again. Maybe I am misunderstanding when Comet should be
 used. In my application, people search for web pages. I do a lot of
 processing for each resulting page. First I just display the links and
 then as the processing is finished, the links on the page are
 automatically modified with the data I just found for each link. This
 is all working fine.

 But, the session is being shared among all users so if I make one
 search in one browser, and then make another search from another
 browser, I get the results from the first browser.

 David suggested I name each CometActor differently. That is not
 working, though maybe I am not doing it right.

 On Oct 6, 12:01 am, Naftoli Gugenheim naftoli...@gmail.com wrote:
  What do you mean?
 
  -
 
  jackjack.wid...@gmail.com wrote:
 
  i guess you meant put the snippet right in the CometActor. Ok. Now I'm
  getting it.
 
  On Oct 5, 11:46 pm, Jack Widman jack.wid...@gmail.com wrote:
 
 
 
   Sorry if this is a dumb question but in lift:comet type=Search
   name={searchString}/, what is searchString? This is in an html file. I
 am
   obviously missing something.
 
   On Mon, Oct 5, 2009 at 2:40 PM, David Pollak
   feeder.of.the.be...@gmail.comwrote:
 
On Mon, Oct 5, 2009 at 10:27 AM, Jack Widman jack.wid...@gmail.com
 wrote:
 
Understood. My intention is to send a ShutDown message to the
 CometActor
when somebody closes the browser. I need this so that when they
 visit the
page in a browser again, the CometActor is 'reset'.
 
First, there's no way to determine if the browser window is closed.
 
Second, *DO NOT* send a ShutDown message to the CometActor.  This is
 an
internal Lift piece of housekeeping.  If you do this, you will break
 stuff.
 Don't do it.  (There is a reason the message is not private, but it
 should
not be used for this purpose.)
 
CometActors can be named:
 
lift:comet type=Search name={searchString}/
 
You can then have a separate CometActor for each searchString.
  Voila...
you get what you want.  Now, how do you make then CometActor go away
 when
it's not being used anymore?
 
In your CometActor:
 override def lifespan: Box[TimeSpan] = Full(3 minutes)
 
That means if a CometActor does not appear on a page for 3 minutes,
 it's
removed from the session.  If the named CometActor is requested
 again, a new
one will be created.
 
On Mon, Oct 5, 2009 at 1:18 PM, marius d. marius.dan...@gmail.com
 wrote:
 
HTTP session termination does not equate with browser-close event.
 
Br's,
Marius
 
On Oct 5, 3:22 pm, Jack Widman jack.wid...@gmail.com wrote:
 Yes, thats what I meant. Thanks
 
 On Mon, Oct 5, 2009 at 4:10 AM, Timothy Perrett
timo...@getintheloop.euwrote:
 
  But you can do it on session termination (which is what you
 probably
  want):
 
   
 http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scalado...
 
  Checkout the method:
 
  registerCleanupFunc
 
  Cheers, Tim
 
  On Oct 5, 8:54 am, Viktor Klang viktor.kl...@gmail.com
 wrote:
   On Mon, Oct 5, 2009 at 6:50 AM, jack jack.wid...@gmail.com
wrote:
 
I would like to call a function when the browser is closed.
 How
do I
do this?
 
   You cannot reliably do this.
 
   --
   Viktor Klang
 
   Blog: klangism.blogspot.com
   Twttr: viktorklang
 
   Lift Committer - liftweb.com
   AKKA Committer - akkasource.org
   Cassidy - github.com/viktorklang/Cassidy.git
   SoftPub founder:http://groups.google.com/group/softpub
 
 --
 Jack
 
--
Jack
 
--
Lift, the simply functional web frameworkhttp://liftweb.net
Beginning Scalahttp://www.apress.com/book/view/1430219890
Follow me:http://twitter.com/dpp
Surf the harmonics
 
   --
   Jack


 



-- 
Jack

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com