On 21 feb., 03:18, Nolan Darilek <[email protected]> wrote:
> I wrote my first comet actor today. Pretty neat stuff, and it was less
> difficult and painful than I expected. :) I'm having a bit of an issue
> figuring out how to render exactly what I want, though.
>
> My comet actor tracks a series of data imports, and since the import
> statuses change pretty rapidly, it makes more sense to poll at regular
> intervals and redraw the entire table of imports or perhaps the
> individual row than it does to do something more complex--at least for
> now. What I want to do, though, is display the table but only if there
> are imports active. If there are none, just display a paragraph stating
> that none are currently in progress.
>
> My issue is that since import statuses are displayed in a table, and
> since there may be two or three, I seem to either be able to display an
> empty table or nothing at all. Here's my template:
>
> <lift:surround with="default" at="content">
> <table>
> <tr>
> <th>Name</th><th>Complete</th><th>Total</th><th>Status</th>
> </tr>
> <lift:comet type="ImportMonitor">
> <tr>
> <td><import:name/></td>
> <td><import:complete/></td>
> <td><import:total/></td>
> <td><import:status/></td>
> </tr>
> </lift:comet>
> </table>
> </lift:surround>
try this:
<lift:comet type="ImportMonitor">
<pre: mytable>
<table>
<tr>
<th>Name</th><th>Complete</th><th>Total</th><th>Status</th>
</tr>
<tr>
<td><import:name/></td>
<td><import:complete/></td>
<td><import:total/></td>
<td><import:status/></td>
</tr>
</table>
</pre: mytable>
</pre: nocontent>
Some content here
</pre: nocontent>
</lift:comet>
In your comet you have:
def defaultPrefix: Box[String] = Full()
def render = {
val table = Helpers.template(defaultXml, "pre", "table") openOr
NodeSeq.Empty
val noContent = Helpers.template(defaultXml, "pre", "nocontent")
openOr NodeSeq.Empty
//Choose here which one you want to render. Also on these
fragments, you can further apply bind.
}
>
> If I try putting the table into another template and having
> ImportMonitor return <lift:embed>, I seem to get nothing. If I move the
> <table> into the <lift:comet>, I get an entire table for each individual
> import.
from your Comet actor render method you could probably return
<lift:embed> and achieve a similar effect as I exemplified.
>
> The only thing that occurs to me is to define the <table> in the code of
> my render method. Is this my only option? Or am I missing something obvious?
No, see above.
>
> Also, how are comet actors timed out? I notice that if I kill the
> Firefox tab, I still get my printlns from the actor on my console, and I
> don't see the debugging code around my unsubscription mechanism
> triggered. Should I be doing something else to get localShutdown
> triggering, or does that happen when the sessions are cleaned up?
Yes when the session terminates. Or you could send a ShutDown message
to your actor. You can also implement
lifeSpan method in your CometActor. It will define for how long your
comet actor will live.
> If
> shutdown methods are only run on session expiration, is there any other
> way to tell a master publishing actor that it doesn't have to do any
> work on the behalf of a listener that no longer pays attention?
>
> Thanks.
--
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en.