[Seaside] HTML/Javascript list and Comet updating it's contents.

Rob Withers reefedjib at gmail.com
Sat Oct 9 20:25:47 UTC 2010


Thanks, Lukas.  This example does raise some questions for me.  One class of 
questions is regarding the use of jQuery.   Is there any documentation I 
could read about it?  I'll put these questions in a separate email to keep 
this one short.

The other question relates to what I am trying to do, and I will start with 
that.  I am trying to write a Chat application.

1) appending items to a list.   I notice that your approach here maintains a 
list on the server and adds an item to that list and then re-renders the 
entire table.  Since I am trying to write a chat application, this will work 
for the list of users, but not for the message traffic in a particular chat 
session, since I do not intend to keep the messages at the server.  I took a 
look at the CTChat example I see and it looks like the pertinent method is 
#push:with:.

push: aString with: aBlock
	"This code pushes the new message to all its clients. With the exception of 
part 2 adding the message itself, all other parts are optional."

	self pusher javascript: [ :script |
		script add: ((script jQuery: #messages)
		"1. limit listing to 20 messages"
			children;
			sliceFrom: 0 to: -19;
			remove;
			end;
		"2. append message to bottom"
			append: [ :html | self renderMessage: aBlock class: aString on: html ];
			end;
		"3. scroll to bottom"
			scrollTop: 65536) ]

So, what is (script jQuery: #messages) doing?  What type of object is the 
result?  Is the server getting the list of messages from the client?  Or is 
aBlock (a String) and aString being sent to the client and this script is 
running on the client?  I am not clear on the sequence of cascaded messages 
sent: (#children; #sliceFrom:to:, #remove, #end, #append:, #end, 
#scrollTop:).

Can you give me a quick explanation?

Thanks,
Rob


--------------------------------------------------
From: "Lukas Renggli" <renggli at gmail.com>
Sent: Saturday, October 09, 2010 5:06 AM
To: "Seaside - general discussion" <seaside at lists.squeakfoundation.org>
Subject: Re: [Seaside] HTML/Javascript list and Comet updating it's 
contents.

> Have a look at:
>
> Name: Comet-Examples-lr.22
> Author: lr
> Time: 9 October 2010, 11:06:01 am
> UUID: 3ab59a42-c1ff-4808-afee-ac0eade27ab3
> Ancestors: Comet-Examples-lr.21
>
> - added the possiblity for new items to CTReport
>
>
> On 9 October 2010 10:46, Lukas Renggli <renggli at gmail.com> wrote:
>> Give me a second, I will try to extend the example.
>>
>> Lukas
>>
>> On 9 October 2010 00:00, Rob Withers <reefedjib at gmail.com> wrote:
>>> Lukas,
>>>
>>> Excellent!  I checked out that example and it demonstrates how to 
>>> display a
>>> list using javascript.   What I don't see, and it could be staring me in 
>>> the
>>> face, is a way to add new items (or remove them) with the list using 
>>> Comet.
>>>
>>> Thanks,
>>> Rob
>>>
>>> --------------------------------------------------
>>> From: "Lukas Renggli" <renggli at gmail.com>
>>> Sent: Friday, October 08, 2010 5:03 PM
>>> To: "Seaside - general discussion" <seaside at lists.squeakfoundation.org>
>>> Subject: Re: [Seaside] HTML/Javascript list and Comet updating it's
>>> contents.
>>>
>>>> There is an example application included with the comet package called
>>>> CTReport or something (I don't have an image at hand right now) that
>>>> does exactly that.
>>>>
>>>> Lukas
>>>>
>>>> On Friday, October 8, 2010, Rob Withers <reefedjib at gmail.com> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I am struggling to figure out a way to proceed.  I want to have a list
>>>>> that displays elements from my model.  When I add an element, I want 
>>>>> to
>>>>> update the page with Comet.  I searched the web for examples, but only 
>>>>> found
>>>>> examples using other frameworks.  I do not know how to begin.
>>>>>
>>>>> I don't think using orderedList, unorderedList or table is sufficient 
>>>>> to
>>>>> do what I want.  I don't see a way to add items to these lists.  I am
>>>>> completely confused about how to render a list in Javascript.  I am 
>>>>> guessing
>>>>> I need an Array of values and a Table/TableRow/TableData to display 
>>>>> them.
>>>>> Not sure how to do this nor add items.  I am looking for example code.
>>>>>
>>>>> Any assistance would be greatly appreciated.
>>>>>
>>>>> Thanks,
>>>>> Rob
>>>>> _______________________________________________
>>>>> seaside mailing list
>>>>> seaside at lists.squeakfoundation.org
>>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>>>
>>>>
>>>> --
>>>> Lukas Renggli
>>>> www.lukas-renggli.ch
>>>> _______________________________________________
>>>> seaside mailing list
>>>> seaside at lists.squeakfoundation.org
>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>>
>>> _______________________________________________
>>> seaside mailing list
>>> seaside at lists.squeakfoundation.org
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>
>>
>>
>>
>> --
>> Lukas Renggli
>> www.lukas-renggli.ch
>>
>
>
>
> -- 
> Lukas Renggli
> www.lukas-renggli.ch
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> 


More information about the seaside mailing list