[Seaside] Strategies for bulky renders/updates
johan at inceptive.be
Sun Mar 13 12:56:01 UTC 2011
The solution boils down to the following:
- have a unique identifier for each of the objects that allows a mapping from the identifier back to the object (e.g. we have unique keys for all objects in our db)
The first item depends on how your application works. In the snippets below, I assume that <yourObjectRegistry> is a dictionary that allows a mapping from id to the object. These snippets illustrate how to achieve the second and third item.
html document addLoadScript:
((html jQuery ajax
callback: [:id | (yourObjectRegistry at: id) doYourAction ]
value: (JSStream on: 'id')) asFunction: #(id))
onClick: (JSStream on: 'clickAction($(this).id)');
with: [ ... ]
I hope this helps you out. But I'm not sure if that will really improve page rendering speed or size. The size of the callback url is not that much different from the size of the onClick event script.
In our case, by doing the above, we did not need to include the triggering of a jQuery editable for each generated html element. That resulted in a 10 times page rendering speedup because the load script was not registering the +1000 editables anymore.
But let us know how it went!
On 13 Mar 2011, at 03:21, radoslav hodnicak wrote:
> I've been using seaside with jquery to create quite interactive
> interfaces, using the simplest approach of "everything has its own
> callback". This works well if the dataset you're working with is
> small, but I'm now venturing into territories where it takes seconds
> to receive+render a page, which isn't acceptable.
> For an example of what I'm talking about imagine a page showing a list
> of emails. Every line (email) has a clickable sender, subject, date,
> and a bunch of more actions and icons etc. If you're creating
> anchors/click actions for each field separately, that's easily
> hundreds or thousands of callbacks per page, each needing to be
> generated on the server and sent over the wire. So clearly I need to
> user clicked and do a parametrized request. Which I can do, but I'm
> wondering if someone has figured out a clever way how to map the
> information on the page to smalltalk objects on the server (other than
> using callback registry). Same goes for bulk actions involving
> multiple items ("delete selected" and the like).
> seaside mailing list
> seaside at lists.squeakfoundation.org
More information about the seaside