chat question and two shortcomings

35 views
Skip to first unread message

Andy C

unread,
Apr 15, 2014, 9:59:00 PM4/15/14
to lif...@googlegroups.com
At what point it is decided that the chat content is not displayed and replaced by .../src/main/webapp/_chat_fixed.html actually.  There is really no obvious if and the design seems to rely on side effect and order of evaluation. I would appreciate a sensible explanation.

Also I noticed two bugs:

1) after going to http://demo.liftweb.net/chat and entering different names in two separate chats before posting any messages to them, only one name will be reflected as a current user. I would expect that both divs are being updated from browser, as it happens when separate tabs/windows are used.

2) After opening http://demo.liftweb.net/chat in FF and entering two short name (e.g. 1 character long),the browser momentarily reveals the content of the chat and hides it again

Thx,
Andy

Vasya Novikov

unread,
Apr 17, 2014, 12:31:02 PM4/17/14
to lif...@googlegroups.com
See here:
https://github.com/fmpwizard/lift_25_samples/blob/master/src/main/scala/net/liftweb/example/comet/Chat.scala#L73
we're using a transformation
("name=when" #> hourFormat(c.when) &
"name=who" #> c.user &
"name=body" #> c.msg)
It replaces html parts with c.user, c.msg. At the last line, we're
applying the transformation to the `li` variable. The `li` is a NodeSeq,
a static chat line with no real data filled in (or any random stuff
filled in because it would be replaced anyway). This `li` could belong
to an object BTW, it's immutable.

Actually, I do love Lift, but I do not know any documentation or example
source that arn really up to date. From my experience, while working
with Lift you have to apply your own sense first, try to find the
expected methods, and only afterwards go to documentation.
Ah, now that I thought about it, I do know 1 source that is up to date.
That is git:/.../lift/framework/ .)

I also remember I had a related talk some time ago at stackoverflow:
http://stackoverflow.com/questions/21876978/lift-2-6-how-to-append-a-nodeseq-rather-than-using-sethtml/21881778#21881778
I tried to write there how I see good ways of learning Lift.
> --
> --
> Lift, the simply functional web framework: http://liftweb.net
> Code: http://github.com/lift
> Discussion: http://groups.google.com/group/liftweb
> Stuck? Help us help you:
> https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Lift" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to liftweb+u...@googlegroups.com
> <mailto:liftweb+u...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Antonio Salazar Cardozo

unread,
Apr 17, 2014, 3:04:33 PM4/17/14
to lif...@googlegroups.com, n1m5-goo...@yandex.ru
The books are generally pretty good because they present one coherent view. That said, Lift does change
fast. The Lift Cookbook tends to be pretty good about staying on top of things thanks to use contributions.
I encourage you to help out with keeping that up to date when possible. Lift is a community effort, as is
its documentation :)

For what it's worth, I'm currently ankle-deep in ripping out the old binding stuff and other things that have
been deprecated or superseded for a while in Lift. Hopefully I'll be neck-deep soon enough heh.
Thanks,
Antonio

Diego Medina

unread,
Apr 19, 2014, 12:26:58 AM4/19/14
to Lift
Hi, 

I'll try to answer your questions:



At what point it is decided that the chat content is not displayed and replaced by .../src/main/webapp/_chat_fixed.html actually.  There is really no obvious if and the design seems to rely on side effect and order of evaluation. I would appreciate a sensible explanation.



it is not that the chat content is replaced with _chat_fixed.html.

First you need some background on comet actors and the different things they provide.

you see:

override lazy val fixedRender

if we go to the original method:


we see:

 /**
   * A part of the CometActor's screen real estate that is not
   * updated by default with reRender().  This block of HTML is
   * useful for the editor part of a Comet-based control where
   * the data is JSON and updated with partialUpdates.
   */
  def fixedRender: Box[NodeSeq] = Empty


so in the chat aexample, we override the method to have the comet actor display the content of the _chat_fixed.html file, which is

which is


I'm not sure where you see that it depends on order of evaluation, and if by side effect you mean, reading a template, it is a web app that does stuff, so there is plenty of side effects, or which side effect are you referring to?



 
Also I noticed two bugs:

1) after going to http://demo.liftweb.net/chat and entering different names in two separate chats before posting any messages to them, only one name will be reflected as a current user. I would expect that both divs are being updated from browser, as it happens when separate tabs/windows are used.


This is a simple example, it is not supposed to be a full feature chat application, you will also notice that it does not ask for a user/pass pair and a lot of other things.

 
2) After opening http://demo.liftweb.net/chat in FF and entering two short name (e.g. 1 character long),the browser momentarily reveals the content of the chat and hides it again



it also happens on Chrome, not sure what is going on, but if you have time to look into it, we will be happy to accept a pull request for the fix.

Thanks

  Diego
 
Thx,
Andy

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Diego Medina
Lift/Scala consultant
di...@fmpwizard.com
http://fmpwizard.telegr.am

Andy C

unread,
Apr 19, 2014, 11:58:21 AM4/19/14
to lif...@googlegroups.com
so in the chat aexample, we override the method to have the comet actor display the content of the _chat_fixed.html file, which is

which is



I think I see that now. Thank you.
 


I'm not sure where you see that it depends on order of evaluation, and if by side effect you mean, reading a template, it is a web app that does stuff, so there is plenty of side effects, or which side effect are you referring to?


For some reason I completely overlooked "  override lazy val fixedRender: Box[NodeSeq] =" which invalidates my question now.



 
Also I noticed two bugs:

1) after going to http://demo.liftweb.net/chat and entering different names in two separate chats before posting any messages to them, only one name will be reflected as a current user. I would expect that both divs are being updated from browser, as it happens when separate tabs/windows are used.


This is a simple example, it is not supposed to be a full feature chat application, you will also notice that it does not ask for a user/pass pair and a lot of other things.


I realize that this is just a simple example. I was just wondering how many instances of Chat object are created when we open http://demo.liftweb.net/chat ?

 
 
2) After opening http://demo.liftweb.net/chat in FF and entering two short name (e.g. 1 character long),the browser momentarily reveals the content of the chat and hides it again



it also happens on Chrome, not sure what is going on, but if you have time to look into it, we will be happy to accept a pull request for the fix.



My intuition says that it is a Liftweb itself. Will spend some time and give a try.

Best,
Andy

Diego Medina

unread,
Apr 19, 2014, 2:16:32 PM4/19/14
to Lift

This is a simple example, it is not supposed to be a full feature chat application, you will also notice that it does not ask for a user/pass pair and a lot of other things.


I realize that this is just a simple example. I was just wondering how many instances of Chat object are created when we open http://demo.liftweb.net/chat ?



When using CometActors, by default we define them as a class, not an object ()you can define snippets as class or object, and that means that a snippet that is an object will result  in just one instance per JVM (or classloader for those who load multiple war files per jvm instance, if you define a snippet as a class, each request gets its own "snippet instance"). When it comes to comet actors, there is one per session, which translates in one comet per browser window, so multiple tabs resuse the same comet actor instance.

There are ways around this, where you can have multiple instances of a comet actor of the same class in the same session. you achieve this by giving each comet actor a "name"

you can give a comet actor a name when you declare them in an html page, like:

<div data-lift="comet?type=Chat&name=lift-room"></div>

there are other ways too, where you can just have lift assign a random name on each page load.


Hope that helps.

Diego


 
 
 
2) After opening http://demo.liftweb.net/chat in FF and entering two short name (e.g. 1 character long),the browser momentarily reveals the content of the chat and hides it again



it also happens on Chrome, not sure what is going on, but if you have time to look into it, we will be happy to accept a pull request for the fix.



My intuition says that it is a Liftweb itself. Will spend some time and give a try.=

Best,
Andy

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages