Hello,
I have created a simple test application to play around with comet.
it's a "live CRUD table" the comet updates its clients with every
change to the records( There is no database, just a List[Game] in the
Game object). I have three questions about this:
1.I know that Comets won't work with GAE-J, but which application
servers can i use? Or is there one that's "recommended"? Since i had
JBOSS 4.2.3AG already on my system i tried this, but without succes...
2.Is the way i'am using JQuery right way? or maybe, is there a better
way to this?
3. The three case classes: NewGame(g: Game),RemoveGame(g:
Game),UpdateGame(g: Game) all extend GameMsg. In the partial function
highPriority i have tried to match: NewGame(g), RemoveGame(g) and
UpdateGame(g) that doesn't seem to work, but why?
Cheers,
Michel
class GameList extends CometActor with CometListenee{
override def defaultPrefix = Full("entry")
override def parentTag = <tbody></tbody>
override def devMode = false
override def hasOuter = false
protected def registerWith = Game
override def render = new RenderOut( (Game.getGames.flatMap
(bindGameRow(_))).toSeq )
override def highPriority: PartialFunction[Any,Unit] = {
case (g:Game, NewGame()) => partialUpdate(PrependHtml
(this.uniqueId,bindGameRow(g)))
case (g:Game, RemoveGame()) => partialUpdate(RemoveById
(""+g.gid))
case (g:Game, UpdateGame()) => partialUpdate(ReplaceWithById
(""+g.gid, bindGameRow(g)))
}
private def bindGameRow(g:Game) =
<tr id={""+g.gid}>
{bind("id" -> g.gid,
"name" -> SHtml.link("/game", () =>
CurrentGame(Full(g)),
Text(g.gname)),
"players" -> g.playerStatus,
"owner" -> g.creator,
"timestamp" -> <b>{g.createdOn.toString}</b>,
"joinlink" -> SHtml.ajaxButton("Delete game!",
{() => Game ! Game.DeleteGame(g);Noop}))
}
</tr>
}
//some javascript stuff
object RemoveById {
def apply(uid: String) = new RemoveById(uid)
}
class RemoveById(val uid: String) extends JsCmd {
def toJsCmd = "try{jQuery("+ ("#"+uid).encJs + ").remove();} catch
(e) {}"
}
object ReplaceWithById {
def apply(uid: String, nsq: NodeSeq) = new ReplaceWithById(uid,
nsq.toString)
}
class ReplaceWithById(val uid: String, val content:String) extends
JsCmd {
def toJsCmd = "try{jQuery("+("#"+uid).encJs+").replaceWith($('"+
content.encJs +"'));} catch (e) {}"
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---