Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert "Revert "* Working sample application using Forms, Lift actors…

… and Comet actors""

This reverts commit d2cb3d0.

Conflicts:

	project/build/LiftProject.scala
	src/main/resources/props/default.logback.xml
	src/main/scala/bootstrap/liftweb/Boot.scala
	src/main/scala/code/comet/MyLiftActor.scala
	src/main/scala/code/lib/WorkerLiftActor.scala
	src/main/scala/code/snippet/LiftActorForm.scala
	src/main/scala/code/snippet/PlaceCometOnPage.scala
	src/main/webapp/liftactorform.html
	src/main/webapp/myliftactor.html
  • Loading branch information...
commit c6f1c7bab855aceb3e123c4766704d4ae95cdb03 1 parent 88b3231
Diego Medina authored
11 project/build/LiftProject.scala
View
@@ -1,22 +1,27 @@
import sbt._
class LiftProject(info: ProjectInfo) extends DefaultWebProject(info) {
- val liftVersion = "2.3-RC4"
+ val liftVersion = "2.3"
// uncomment the following if you want to use the snapshot repo
// val scalatoolsSnapshot = ScalaToolsSnapshots
+ override def compileOptions = super.compileOptions ++ Seq(Unchecked)
+
// If you're using JRebel for Lift development, uncomment
// this line
// override def scanDirectories = Nil
+ System.setProperty("h2.bindAddress", "127.0.0.1")
+
override def libraryDependencies = Set(
"net.liftweb" %% "lift-webkit" % liftVersion % "compile->default",
"net.liftweb" %% "lift-mapper" % liftVersion % "compile->default",
+ "net.liftweb" %% "lift-json" % liftVersion % "compile->default",
+ "net.liftweb" %% "lift-util" % liftVersion % "compile->default",
+ "net.liftweb" %% "lift-actor" % liftVersion % "compile->default",
"org.mortbay.jetty" % "jetty" % "6.1.22" % "test->default",
- "junit" % "junit" % "4.5" % "test->default",
"ch.qos.logback" % "logback-classic" % "0.9.26",
- "org.scala-tools.testing" %% "specs" % "1.6.6" % "test->default",
"com.h2database" % "h2" % "1.2.138"
) ++ super.libraryDependencies
}
14 src/main/resources/props/default.logback.xml
View
@@ -0,0 +1,14 @@
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <layout class="ch.qos.logback.classic.PatternLayout">
+ <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
+ </layout>
+ </appender>
+
+ <logger name="com.fmpwizard.code.snippet" level="info"/>
+ <logger name="com.fmpwizard.code" level="info"/>
+ <root level="error">
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
7 src/main/scala/bootstrap/liftweb/Boot.scala
View
@@ -10,7 +10,6 @@ import sitemap._
import Loc._
import mapper._
-//import code.model._
/**
@@ -47,10 +46,14 @@ class Boot {
Menu.i("Wiring") / "wiring",
Menu.i("Wiring2") / "wiring2",
Menu.i("Invoice") / "invoice_wiring",
+ Menu.i("LiftActor") / "liftactorform" submenus (
+ Menu.i("LiftActor In Action") / "myliftactor" >> Hidden
+ )
+ ,
// more complex because this menu allows anything in the
// /static path to be visible
- Menu(Loc("Static", Link(List("static"), true, "/static/index"),
+ Menu(Loc("Static", Link(List("static"), true, "/static/index"),
"Static Content")))
170 src/main/scala/code/comet/MyLiftActor.scala
View
@@ -0,0 +1,170 @@
+package com.fmpwizard.code
+package comet
+
+
+import scala.xml.{NodeSeq, Text, Elem}
+
+import net.liftweb._
+import util._
+import actor._
+import http._
+import common.{Box, Full,Logger}
+import mapper.{OrderBy, Descending, SelectableField}
+import http.SHtml._
+import http.S._
+import http.js.JsCmds.{SetHtml, SetValueAndFocus, Replace}
+import http.js.jquery.JqJE._
+import net.liftweb.http.js.JE.Str
+import Helpers._
+
+
+/**
+ * This is the message we pass around to
+ * register each named comet actor with a dispatcher that
+ * only updates the specific version it monitors
+ */
+case class registerCometActor(actor: CometActor, version: String)
+
+/**
+ * The message we pass around to update the UI
+ * once we are done with our long running process
+ */
+case class DoneMessage(CometActorName: String, City: String, State: String)
+
+class Myliftactor extends CometActor with Logger {
+
+ override def defaultPrefix = Full("comet")
+
+ // time out the comet actor if it hasn't been on a page for 2 minutes
+ override def lifespan = Full(120 seconds)
+
+
+
+ /**
+ * On page load, this method does a full page render
+ */
+ def render= {
+ "#result *" #> "5 seconds after you submit, you will see a new message here."
+
+ }
+
+ /**
+ * We can get two kinds of messages
+ * 1- A DoneMessage, which has info about the long
+ * running process we just finished.
+ * A LiftActor sends this message
+ *
+ * 2- A string which is the version the comet actor is displaying info about
+ * On page load we get this message
+ *
+ */
+ override def lowPriority: PartialFunction[Any,Unit] = {
+ case DoneMessage(cometActorName, city, state) => {
+ info("Comet Actor %s will do a partial update".format(this))
+
+ /**
+ * each td in the html grid has an id that is
+ * [0-9] + browser name
+ * I use this to uniquely identify which cell to update
+ *
+ */
+ partialUpdate(
+ SetHtml("result", <span>I finished processing your form.<br />
+ You submitted <b>{state}, {city}</b></span>)
+ )
+ }
+ case Full(name: String)=> {
+ info("[URL]: CometActor monitoring session: %s".format(name))
+
+ /**
+ * We get the DispatcherActor that sends message to all the
+ * CometActors that are displaying a specific version number.
+ * And we register ourselves with the dispatcher
+ */
+
+ //name map{n => MyListeners.listenerFor(n) ! registerCometActor(this, n) }
+ MyListeners.listenerFor(name) ! registerCometActor(this, name)
+ //MyListeners.listenerFor(name)
+ info("Registering comet actor: %s".format(this))
+ reRender()
+ }
+ case _ => info("Not sure how we got here.")
+ }
+
+
+}
+
+/**
+ * This class keeps a list of comet actors that need to update the UI
+ * if we get new data through the rest api
+ */
+class DispatcherActor(name: String) extends LiftActor with Logger{
+
+ //info("DispatcherActor got version: %s".format(name))
+ private var doneMessage= DoneMessage("", "Asheville", "North Carolina")
+ private var cometActorsToUpdate: List[CometActor]= List()
+
+ def createUpdate = doneMessage
+
+ override def messageHandler = {
+ /**
+ * if we do not have this actor in the list, add it (register it)
+ */
+ case registerCometActor(actor, name) =>
+ if(cometActorsToUpdate.contains(actor) == false){
+ info("We are adding actor: %s to the list".format(actor))
+ cometActorsToUpdate= actor :: cometActorsToUpdate
+ } else {
+ info("The list so far is %s".format(cometActorsToUpdate))
+ }
+
+ /**
+ * Go through the the list of actors and send them a cellToUpdate message
+ */
+ case DoneMessage(name, city, state) => {
+ doneMessage = DoneMessage(name, city, state)
+ info("We will update these comet actors: %s showing name: %s".format(
+ cometActorsToUpdate, name))
+ cometActorsToUpdate.foreach(_ ! doneMessage)
+ }
+ case _ => "Bye"
+ }
+
+}
+
+
+/**
+ * Keep a map of versions -> dispatchers, if no dispatcher is found, create one
+ * comet actors get the ref to their dispatcher using this object,
+ * so they can register themselves and the rest
+ * api gets the dispatcher that is monitoring a specific version
+ *
+ */
+object MyListeners extends Logger{
+ //How about creating a ListenerManager (a separate Actor)
+ //for each of the items you're going to have:
+
+
+ private var listeners: Map[String, LiftActor] = Map()
+
+ def listenerFor(str: String): LiftActor = synchronized {
+ listeners.get(str) match {
+ case Some(a) => info("Our map is %s".format(listeners)); a
+ case None => {
+ val ret = new DispatcherActor(str)
+ listeners += str -> ret
+ info("Our map is %s".format(listeners))
+ ret
+ }
+ }
+ }
+
+
+
+ //So, you'll have a separate dispatcher for each of your URL parameters
+ //and the CometActors can register with them and the REST thing can find
+ //them to send the messages.
+
+
+
+}
43 src/main/scala/code/lib/WorkerLiftActor.scala
View
@@ -0,0 +1,43 @@
+package com.fmpwizard.code
+package lib
+
+
+import net.liftweb._
+import util._
+import actor._
+import common.Logger
+
+import comet._
+import comet.MyListeners._
+import snippet.cometName
+
+class WorkerLiftActor extends LiftActor with Logger{
+
+
+ private var doneMessage= DoneMessage("name", "Asheville", "North Carolina")
+
+ def createUpdate = doneMessage
+
+ override def messageHandler = {
+ /**
+ * Go through the the list of actors and send them a cellToUpdate message
+ */
+ case DoneMessage(name, city, state) => {
+ doneMessage = DoneMessage(name, city, state)
+
+ /**
+ * Here we pretend to do some
+ * intensive work that takes about
+ * 5 seconds
+ */
+
+ Thread.sleep(5000)
+ listenerFor(name) match {
+ case a: LiftActor => info("LiftActor is done, do the update! %s".format(name)); a ! doneMessage
+ case _ => info("No actor to send an update")
+ }
+ }
+ case x => "I don't know what to do with this message: %s".format(x)
+ }
+
+}
376 src/main/scala/code/snippet/LiftActorForm.scala
View
@@ -0,0 +1,376 @@
+package com.fmpwizard.code
+package snippet
+
+/*
+ * Copyright 2007-2010 WorldWide Conferencing, LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import scala.xml._
+import net.liftweb._
+import actor._
+import http._
+import S._
+import SHtml._
+import common._
+import util._
+import Helpers._
+import js._
+import JsCmds._
+import js.jquery._
+
+import comet._
+import comet.MyListeners._
+import lib._
+
+class Liftactorform extends Logger{
+
+ var state= CitiesAndStates4.state
+ var city= CitiesAndStates4.city
+
+
+ def stateDropDown = SHtml.ajaxSelect(
+ CitiesAndStates4.states.map(i => (i, i)),
+ Full(1.toString),
+ selected => {
+ //What to do when you select an entry
+ Info.selectedState.set(selected)
+ state= selected
+ city= CitiesAndStates4.citiesFor(state).head
+ Noop
+ }
+ )
+
+ def cityDropDown(in: NodeSeq) =
+ WiringUI.toNode(in, Info.cities, JqWiringSupport.fade)((d, ns) => cityChoice(state))
+
+
+ private object Info {
+ val selectedState= ValueCell(state)
+ //you cannot do Info.cities.set(new value), so we add a new val
+ val cityValueCell= ValueCell("")
+ val cities= selectedState.lift(_ + "")
+ }
+ /**
+ * Generate the City drop down menu
+ */
+ private def cityChoice(state: String): Elem = {
+ val cities = CitiesAndStates4.citiesFor(state)
+ val first = cities.head
+ SHtml.ajaxSelect(
+ cities.map(i => (i, i)),
+ Full(1.toString),
+ selected => {
+ //What to do when you select an entry
+ Info.cityValueCell.set(selected)
+ city= selected
+ Noop
+
+ }
+ )
+ }
+
+
+
+ // bind the view to the dynamic HTML
+ def show(xhtml: Group): NodeSeq = {
+ info("sss %s".format(cometName.is))
+ val diego= cometName.is.openOr("1")
+ info("sss %s".format(diego))
+ bind("select", xhtml,
+ "city" -> cityChoice(state) % ("id" -> "city_select"),
+ "submit" -> submit(?("Save"),
+ () =>
+ {
+ S.notice("Wait 5 seconds and you will see some magic.")
+ val workerLiftActor = new WorkerLiftActor
+ workerLiftActor ! DoneMessage(
+ diego , city, state
+ )
+ }))
+ }
+}
+
+object CitiesAndStates4 extends Logger {
+ val citiesAndStates = List("Alabama" -> "Birmingham",
+ "Alabama" -> "Huntsville",
+ "Alabama" -> "Mobile",
+ "Alabama" -> "Montgomery",
+ "Alaska" -> "Anchorage municipality",
+ "Arizona" -> "Chandler",
+ "Arizona" -> "Gilbert town",
+ "Arizona" -> "Glendale",
+ "Arizona" -> "Mesa",
+ "Arizona" -> "Peoria",
+ "Arizona" -> "Phoenix",
+ "Arizona" -> "Scottsdale",
+ "Arizona" -> "Tempe",
+ "Arizona" -> "Tucson",
+ "Arkansas" -> "Little Rock",
+ "California" -> "Anaheim",
+ "California" -> "Antioch",
+ "California" -> "Bakersfield",
+ "California" -> "Berkeley",
+ "California" -> "Burbank",
+ "California" -> "Chula Vista",
+ "California" -> "Concord",
+ "California" -> "Corona",
+ "California" -> "Costa Mesa",
+ "California" -> "Daly City",
+ "California" -> "Downey",
+ "California" -> "El Monte",
+ "California" -> "Elk Grove",
+ "California" -> "Escondido",
+ "California" -> "Fairfield",
+ "California" -> "Fontana",
+ "California" -> "Fremont",
+ "California" -> "Fresno",
+ "California" -> "Fullerton",
+ "California" -> "Garden Grove",
+ "California" -> "Glendale",
+ "California" -> "Hayward",
+ "California" -> "Huntington Beach",
+ "California" -> "Inglewood",
+ "California" -> "Irvine",
+ "California" -> "Lancaster",
+ "California" -> "Long Beach",
+ "California" -> "Los Angeles",
+ "California" -> "Modesto",
+ "California" -> "Moreno Valley",
+ "California" -> "Norwalk",
+ "California" -> "Oakland",
+ "California" -> "Oceanside",
+ "California" -> "Ontario",
+ "California" -> "Orange",
+ "California" -> "Oxnard",
+ "California" -> "Palmdale",
+ "California" -> "Pasadena",
+ "California" -> "Pomona",
+ "California" -> "Rancho Cucamonga",
+ "California" -> "Richmond",
+ "California" -> "Riverside",
+ "California" -> "Roseville",
+ "California" -> "Sacramento",
+ "California" -> "Salinas",
+ "California" -> "San Bernardino",
+ "California" -> "San Buenaventura (Ventura)",
+ "California" -> "San Diego",
+ "California" -> "San Francisco",
+ "California" -> "San Jose",
+ "California" -> "Santa Ana",
+ "California" -> "Santa Clara",
+ "California" -> "Santa Clarita",
+ "California" -> "Santa Rosa",
+ "California" -> "Simi Valley",
+ "California" -> "Stockton",
+ "California" -> "Sunnyvale",
+ "California" -> "Thousand Oaks",
+ "California" -> "Torrance",
+ "California" -> "Vallejo",
+ "California" -> "Visalia",
+ "California" -> "West Covina",
+ "Colorado" -> "Arvada",
+ "Colorado" -> "Aurora",
+ "Colorado" -> "Colorado Springs",
+ "Colorado" -> "Denver",
+ "Colorado" -> "Fort Collins",
+ "Colorado" -> "Lakewood",
+ "Colorado" -> "Pueblo",
+ "Colorado" -> "Thornton",
+ "Colorado" -> "Westminster",
+ "Connecticut" -> "Bridgeport",
+ "Connecticut" -> "Hartford",
+ "Connecticut" -> "New Haven",
+ "Connecticut" -> "Stamford",
+ "Connecticut" -> "Waterbury",
+ "District of Columbia" -> "Washington",
+ "Florida" -> "Cape Coral",
+ "Florida" -> "Clearwater",
+ "Florida" -> "Coral Springs",
+ "Florida" -> "Fort Lauderdale",
+ "Florida" -> "Gainesville",
+ "Florida" -> "Hialeah",
+ "Florida" -> "Hollywood",
+ "Florida" -> "Jacksonville",
+ "Florida" -> "Miami",
+ "Florida" -> "Miramar",
+ "Florida" -> "Orlando",
+ "Florida" -> "Pembroke Pines",
+ "Florida" -> "Pompano Beach",
+ "Florida" -> "Port St. Lucie",
+ "Florida" -> "St. Petersburg",
+ "Florida" -> "Tallahassee",
+ "Florida" -> "Tampa",
+ "Georgia" -> "Athens-Clarke County (balance)",
+ "Georgia" -> "Atlanta",
+ "Georgia" -> "Augusta-Richmond County (balance)",
+ "Georgia" -> "Columbus",
+ "Georgia" -> "Savannah",
+ "Hawaii" -> "Honolulu CDP",
+ "Idaho" -> "Boise City",
+ "Illinois" -> "Aurora",
+ "Illinois" -> "Chicago",
+ "Illinois" -> "Elgin",
+ "Illinois" -> "Joliet",
+ "Illinois" -> "Naperville",
+ "Illinois" -> "Peoria",
+ "Illinois" -> "Rockford",
+ "Illinois" -> "Springfield",
+ "Indiana" -> "Evansville",
+ "Indiana" -> "Fort Wayne",
+ "Indiana" -> "Indianapolis city (balance)",
+ "Indiana" -> "South Bend",
+ "Iowa" -> "Cedar Rapids",
+ "Iowa" -> "Des Moines",
+ "Kansas" -> "Kansas City",
+ "Kansas" -> "Olathe",
+ "Kansas" -> "Overland Park",
+ "Kansas" -> "Topeka",
+ "Kansas" -> "Wichita",
+ "Kentucky" -> "Lexington-Fayette",
+ "Kentucky" -> "Louisville/Jefferson County (balance)",
+ "Louisiana" -> "Baton Rouge",
+ "Louisiana" -> "Lafayette",
+ "Louisiana" -> "New Orleans",
+ "Louisiana" -> "Shreveport",
+ "Maryland" -> "Baltimore",
+ "Massachusetts" -> "Boston",
+ "Massachusetts" -> "Cambridge",
+ "Massachusetts" -> "Lowell",
+ "Massachusetts" -> "Springfield",
+ "Massachusetts" -> "Worcester",
+ "Michigan" -> "Ann Arbor",
+ "Michigan" -> "Detroit",
+ "Michigan" -> "Flint",
+ "Michigan" -> "Grand Rapids",
+ "Michigan" -> "Lansing",
+ "Michigan" -> "Sterling Heights",
+ "Michigan" -> "Warren",
+ "Minnesota" -> "Minneapolis",
+ "Minnesota" -> "St. Paul",
+ "Mississippi" -> "Jackson",
+ "Missouri" -> "Independence",
+ "Missouri" -> "Kansas City",
+ "Missouri" -> "Springfield",
+ "Missouri" -> "St. Louis",
+ "Montana" -> "Billings",
+ "Nebraska" -> "Lincoln",
+ "Nebraska" -> "Omaha",
+ "Nevada" -> "Henderson",
+ "Nevada" -> "Las Vegas",
+ "Nevada" -> "North Las Vegas",
+ "Nevada" -> "Reno",
+ "New Hampshire" -> "Manchester",
+ "New Jersey" -> "Elizabeth",
+ "New Jersey" -> "Jersey City",
+ "New Jersey" -> "Newark",
+ "New Jersey" -> "Paterson",
+ "New Mexico" -> "Albuquerque",
+ "New York" -> "Buffalo",
+ "New York" -> "New York",
+ "New York" -> "Rochester",
+ "New York" -> "Syracuse",
+ "New York" -> "Yonkers",
+ "North Carolina" -> "Cary town",
+ "North Carolina" -> "Charlotte",
+ "North Carolina" -> "Durham",
+ "North Carolina" -> "Fayetteville",
+ "North Carolina" -> "Greensboro",
+ "North Carolina" -> "Raleigh",
+ "North Carolina" -> "Winston-Salem",
+ "Ohio" -> "Akron",
+ "Ohio" -> "Cincinnati",
+ "Ohio" -> "Cleveland",
+ "Ohio" -> "Columbus",
+ "Ohio" -> "Dayton",
+ "Ohio" -> "Toledo",
+ "Oklahoma" -> "Norman",
+ "Oklahoma" -> "Oklahoma City",
+ "Oklahoma" -> "Tulsa",
+ "Oregon" -> "Eugene",
+ "Oregon" -> "Portland",
+ "Oregon" -> "Salem",
+ "Pennsylvania" -> "Allentown",
+ "Pennsylvania" -> "Erie",
+ "Pennsylvania" -> "Philadelphia",
+ "Pennsylvania" -> "Pittsburgh",
+ "Rhode Island" -> "Providence",
+ "South Carolina" -> "Charleston",
+ "South Carolina" -> "Columbia",
+ "South Dakota" -> "Sioux Falls",
+ "Tennessee" -> "Chattanooga",
+ "Tennessee" -> "Clarksville",
+ "Tennessee" -> "Knoxville",
+ "Tennessee" -> "Memphis",
+ "Tennessee" -> "Nashville-Davidson (balance)",
+ "Texas" -> "Abilene",
+ "Texas" -> "Amarillo",
+ "Texas" -> "Arlington",
+ "Texas" -> "Austin",
+ "Texas" -> "Beaumont",
+ "Texas" -> "Brownsville",
+ "Texas" -> "Carrollton",
+ "Texas" -> "Corpus Christi",
+ "Texas" -> "Dallas",
+ "Texas" -> "Denton",
+ "Texas" -> "El Paso",
+ "Texas" -> "Fort Worth",
+ "Texas" -> "Garland",
+ "Texas" -> "Grand Prairie",
+ "Texas" -> "Houston",
+ "Texas" -> "Irving",
+ "Texas" -> "Killeen",
+ "Texas" -> "Laredo",
+ "Texas" -> "Lubbock",
+ "Texas" -> "McAllen",
+ "Texas" -> "McKinney",
+ "Texas" -> "Mesquite",
+ "Texas" -> "Midland",
+ "Texas" -> "Pasadena",
+ "Texas" -> "Plano",
+ "Texas" -> "San Antonio",
+ "Texas" -> "Waco",
+ "Utah" -> "Provo",
+ "Utah" -> "Salt Lake City",
+ "Utah" -> "West Valley City",
+ "Virginia" -> "Alexandria",
+ "Virginia" -> "Arlington CDP",
+ "Virginia" -> "Chesapeake",
+ "Virginia" -> "Hampton",
+ "Virginia" -> "Newport News",
+ "Virginia" -> "Norfolk",
+ "Virginia" -> "Portsmouth",
+ "Virginia" -> "Richmond",
+ "Virginia" -> "Virginia Beach",
+ "Washington" -> "Bellevue",
+ "Washington" -> "Seattle",
+ "Washington" -> "Spokane",
+ "Washington" -> "Tacoma",
+ "Washington" -> "Vancouver",
+ "Wisconsin" -> "Green Bay",
+ "Wisconsin" -> "Madison",
+ "Wisconsin" -> "Milwaukee")
+
+
+
+
+ val states = citiesAndStates.map(_._1).distinct
+
+ val state: String = states.head
+
+ def citiesFor(state: String): List[String] = citiesAndStates.filter(_._1 == state).map(_._2)
+
+ val city: String= citiesFor(state).head
+
+}
47 src/main/scala/code/snippet/PlaceCometOnPage.scala
View
@@ -0,0 +1,47 @@
+package com.fmpwizard.code
+package snippet
+
+
+import scala.xml.NodeSeq
+
+import net.liftweb._
+import util._
+import actor._
+import http._
+import Helpers._
+import common.{Full, Logger, Box, Empty, Failure}
+
+
+object cometName extends SessionVar[Box[String]](Empty)
+
+/**
+ * This object adds a ComeActor of type Myliftactor with a name == random string
+ * This allows having multiple tabs open displaying data for different contexts
+ */
+object PlaceCometOnPage extends Logger{
+
+
+
+ def render(xhtml: NodeSeq): NodeSeq = {
+ val id = Helpers.nextFuncName
+ info("The current cometActor name is %s".format(cometName.is))
+ cometName.is match {
+ case Empty => cometName.set(Full(id))
+ case _ => Unit
+
+
+ }
+
+ info("The current cometActor name is %s".format(cometName.is))
+
+ /**
+ * You can set the id of the comet actor to be something you know the
+ * value in advance. Using something like S.param("query_param")
+ * or using the Menu.Param technique
+ */
+ //val id= "notifier" + S.param("q")
+ info("Using CometActor with name: %s".format(cometName.is))
+ for (sess <- S.session) sess.sendCometActorMessage("Myliftactor", cometName.is, cometName.is)
+ <lift:comet type="Myliftactor" name={cometName.is.openOr("noName")}>{xhtml}</lift:comet>
+ }
+}
3  src/main/scala/code/snippet/Wiring2.scala
View
@@ -1,4 +1,5 @@
-package com.fmpwizard.code.snippet
+package com.fmpwizard.code
+package snippet
/*
* Copyright 2007-2010 WorldWide Conferencing, LLC
19 src/main/webapp/liftactorform.html
View
@@ -0,0 +1,19 @@
+<lift:surround with="default" at="content">
+ <center><b>Lift Actors in action</b></center>
+
+ <div class="lift:PlaceCometOnPage">
+ <div id="result">Here you'll see a message written by the comet actor</div>
+ </div>
+ <br >
+ Choose city and state:<br>
+ <lift:snippet type="Liftactorform:show" form="post">
+ <span id="xyz" cometname="default"></span>
+ <div>State: <input class="lift:Liftactorform.stateDropDown"></div>
+ <div>City: <span class="lift:Liftactorform.cityDropDown">City</span></div>
+ <select:submit></select:submit>
+ </lift:snippet>
+ <br>
+ <p>This example shows you how after you submit a form, you can fire up
+ an actor that will do some background work, and once it is done, it can
+ tell the user the status of that background work.</p>
+</lift:surround>
11 src/main/webapp/myliftactor.html
View
@@ -0,0 +1,11 @@
+<lift:surround with="default" at="content">
+ <div class="lift:PlaceCometOnPage"></div>
+ <center><b>lift Actor in action</b></center>
+ <br >
+ Choose city and state:<br>
+ <lift:snippet type="Liftactorform:show" form="post">
+ <div>State: <input class="lift:Liftactorform.stateDropDown"></div>
+ <div>City: <span class="lift:Liftactorform.cityDropDown">Tax</span></div>
+ <select:submit></select:submit>
+ </lift:snippet>
+</lift:surround>
Please sign in to comment.
Something went wrong with that request. Please try again.