[Lift] Re: Scope issues with CometActors

2009-08-28 Thread Spencer Uresk
That did the trick, and I understand what is going on much better now. Thank
you!

For some reason my brain is having trouble adjusting to the idea that you
can generate more sophisticated markup in Scala code. I'm still used to the
world of JSF and the like where all the markup is in a separate (non-code)
file and you use EL expressions to accomplish something similar, so this has
been a good example for me.

Thanks again,

- Spencer

On Thu, Aug 27, 2009 at 8:38 PM, David Pollak feeder.of.the.be...@gmail.com
 wrote:

 lift:comet type=YourCometClass name={person_number} /
 The optional name attribute allows you to have different comet actor names
 (e.g., one per person).  You can retrieve the CometActor's name via the name
 method, which returns a Box[String].

 In your CometActor, make sure to:

 override def lifespan = Full(5 minutes)

 This will make the particular CometActor go away if it does not appear on a
 page for a 5 minute span.

 This lets you have a different CometActor per person, but allows you to
 share a single CometActor instance for a given session for a given name
 across browser windows/tabs.

 I hope this helps and I'd suggest against using SessionVars for passing
 setup information to CometActors.


 On Thu, Aug 27, 2009 at 7:28 PM, Spencer Uresk sur...@gmail.com wrote:

 Hey all,

 I'm trying to build an app that takes advantage of the Comet support in
 Lift. This is a simple app that displays all messages from a given person
 and shows new messages as they are added. At first, I struggled with trying
 to pull the request parameter (the url looks like this - /person/1) into my
 CometActor, and then I found a message on the lift board that talked about
 the scope mismatch between the request scope and a CometActor, and
 recommends setting a session variable that the CometActor then reads.

 The scope mismatch makes sense to me, so I tried the suggested way of
 doing it, which worked. However, now when I go back to the home page and
 select another person to view messages for, I still see the the old
 messages. After some testing, it appears that CometActors on the same page
 are not re-created if there is one already active. I can't seem to find any
 method that gets called on it when the page is rendered either, and I am not
 sure how to update the state of the CometActor so that it retrieves the
 proper messages.

 Is there any documentation or examples for using CometActors in
 conjunction with a request parameter like that? Or is there a better way
 altogether for me to be doing this?

 Thank you,

 - Spencer





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

 


--~--~-~--~~~---~--~~
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: Scope issues with CometActors

2009-08-28 Thread David Pollak
On Thu, Aug 27, 2009 at 11:24 PM, Spencer Uresk sur...@gmail.com wrote:

 That did the trick, and I understand what is going on much better now.
 Thank you!

 For some reason my brain is having trouble adjusting to the idea that you
 can generate more sophisticated markup in Scala code.


I think it's okay to have non-display XML appear in your scala code.  My
pattern for something like this is to have view code that looks like:

lift:PersonActor.select
  ... the view template to be passed to the comet actor goes here
/lift:PersonActor.select

And my Scala code looks like:

class PersonActor {
  def select(in: NodeSeq): NodeSeq =
  lift:comet type=PersonComet name={calcName}{in}/lift:comet
}

Thus you're preserving the view code and using the PersonActor snippet to
rewrite the view code to insert the correct name.

It's also a reminder of why Lift's recursive view rendering is so powerful.
 Jorge Ortiz once likened it to a very verbose Lisp.  But the fact that
Lift's templating rules are applied to the results of snippets means that
you have an awful lot of power.

I'm still used to the world of JSF and the like where all the markup is in a
 separate (non-code) file and you use EL expressions to accomplish something
 similar, so this has been a good example for me.

 Thanks again,

 - Spencer

 On Thu, Aug 27, 2009 at 8:38 PM, David Pollak 
 feeder.of.the.be...@gmail.com wrote:

 lift:comet type=YourCometClass name={person_number} /
 The optional name attribute allows you to have different comet actor names
 (e.g., one per person).  You can retrieve the CometActor's name via the name
 method, which returns a Box[String].

 In your CometActor, make sure to:

 override def lifespan = Full(5 minutes)

 This will make the particular CometActor go away if it does not appear on
 a page for a 5 minute span.

 This lets you have a different CometActor per person, but allows you to
 share a single CometActor instance for a given session for a given name
 across browser windows/tabs.

 I hope this helps and I'd suggest against using SessionVars for passing
 setup information to CometActors.


 On Thu, Aug 27, 2009 at 7:28 PM, Spencer Uresk sur...@gmail.com wrote:

 Hey all,

 I'm trying to build an app that takes advantage of the Comet support in
 Lift. This is a simple app that displays all messages from a given person
 and shows new messages as they are added. At first, I struggled with trying
 to pull the request parameter (the url looks like this - /person/1) into my
 CometActor, and then I found a message on the lift board that talked about
 the scope mismatch between the request scope and a CometActor, and
 recommends setting a session variable that the CometActor then reads.

 The scope mismatch makes sense to me, so I tried the suggested way of
 doing it, which worked. However, now when I go back to the home page and
 select another person to view messages for, I still see the the old
 messages. After some testing, it appears that CometActors on the same page
 are not re-created if there is one already active. I can't seem to find any
 method that gets called on it when the page is rendered either, and I am not
 sure how to update the state of the CometActor so that it retrieves the
 proper messages.

 Is there any documentation or examples for using CometActors in
 conjunction with a request parameter like that? Or is there a better way
 altogether for me to be doing this?

 Thank you,

 - Spencer





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




 



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

--~--~-~--~~~---~--~~
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: Scope issues with CometActors

2009-08-27 Thread David Pollak
lift:comet type=YourCometClass name={person_number} /
The optional name attribute allows you to have different comet actor names
(e.g., one per person).  You can retrieve the CometActor's name via the name
method, which returns a Box[String].

In your CometActor, make sure to:

override def lifespan = Full(5 minutes)

This will make the particular CometActor go away if it does not appear on a
page for a 5 minute span.

This lets you have a different CometActor per person, but allows you to
share a single CometActor instance for a given session for a given name
across browser windows/tabs.

I hope this helps and I'd suggest against using SessionVars for passing
setup information to CometActors.

On Thu, Aug 27, 2009 at 7:28 PM, Spencer Uresk sur...@gmail.com wrote:

 Hey all,

 I'm trying to build an app that takes advantage of the Comet support in
 Lift. This is a simple app that displays all messages from a given person
 and shows new messages as they are added. At first, I struggled with trying
 to pull the request parameter (the url looks like this - /person/1) into my
 CometActor, and then I found a message on the lift board that talked about
 the scope mismatch between the request scope and a CometActor, and
 recommends setting a session variable that the CometActor then reads.

 The scope mismatch makes sense to me, so I tried the suggested way of doing
 it, which worked. However, now when I go back to the home page and select
 another person to view messages for, I still see the the old messages. After
 some testing, it appears that CometActors on the same page are not
 re-created if there is one already active. I can't seem to find any method
 that gets called on it when the page is rendered either, and I am not sure
 how to update the state of the CometActor so that it retrieves the proper
 messages.

 Is there any documentation or examples for using CometActors in conjunction
 with a request parameter like that? Or is there a better way altogether for
 me to be doing this?

 Thank you,

 - Spencer

 



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

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---