问候
我有以下课程
package org.developerworks.comet
import net.liftweb.http._
import net.liftweb.common.Full
import net.liftweb.http.S._
import net.liftweb.http.SHtml._
import net.liftweb.http.js.JsCmd
import net.liftweb.http.js.JsCmds._
import net.liftweb.http.js.JE._
import net.liftweb.util.Helpers._
import net.liftweb.util._
import scala.xml.NodeSeq
import org.developerworks.model._
import org.developerworks.actor._
import java.lang.Long
class AuctionActor extends CometActor {
var highBid : TheCurrentHighBid = null
override def defaultPrefix = Full("auction")
val itemId = S.param("itemId").map(Long.parseLong(_)).openOr(0L)
def render = {
def itemView: NodeSeq = {
val item = if (itemId > 0)
ItemMetaData.findByKey(itemId).openOr(ItemMetaData.create)
else ItemMetaData.create
val currBid = item.highBid
val bidAmt = if (currBid.user.isEmpty) 0L else currBid.amount.is
highBid = TheCurrentHighBid(bidAmt, currBid.user.obj.openOr(User.currentUser.open_!))
val minNewBid = highBid.amount + 1L
val button = <button type="button">{S.?("Bid Now!")}</button> %
("onclick" -> ajaxCall(JsRaw("$('#newBid').attr('value')"), bid _))
(<div>
<strong>{item.name}</strong>
<br/>
<div>
Current Bid: ${highBid.amount} by {highBid.user.niceName}
</div>
<div>
New Bid (min: ${minNewBid}) :
<input type="text" id="newBid"/>
{button}
</div>
{item.description}<br/>
</div>)
}
bind("foo" -> <div>{itemView}</div>)
}
def bid(s:String): JsCmd = {
val user = User.currentUser.open_!
Auctioneer ! BidOnItem(itemId, Long.parseLong(s), user)
}
override def localSetup {
Auctioneer !? AddListener(this, this.itemId) match {
case Success(true) => println("Listener added")
case _ => println("Other ls")
}
}
override def localShutdown {
Auctioneer ! RemoveListener(this, this.itemId)
}
override def lowPriority : PartialFunction[Any, Unit] = {
case TheCurrentHighBid(a,u) => {
highBid = TheCurrentHighBid(a,u)
reRender(false)
}
case _ => println("Other lp")
}
}
使用maven编译时发出以下错误:
[错误] AuctionActor.scala:64:错误:找不到:值Auctioneer [INFO]拍卖师! BidOnItem(itemId,Long.parseLong(s),user) [INFO] ^ [错误] AuctionActor.scala:71:错误:未找到:value Auctioneer [INFO]拍卖师!? AddListener(this,this.itemId)匹配{ [INFO] ^ [错误] AuctionActor.scala:83:错误:未找到:值Auctioneer [INFO]拍卖师! RemoveListener(this,this.itemId)
Auctioneer class(LiftActor),使用以下行调用:
import org.developerworks.actor ._
任何人都知道我做错了什么
请帮助
答案 0 :(得分:1)
将Auctioneer
定义为类而不是对象吗?在这种情况下,您需要先实例化actor,然后才能使用它。