scala lift actor,错误:类型不匹配;

时间:2010-10-20 18:39:30

标签: scala lift actor

问候

我正在使用scala版本2.8.0和2.1版本的电梯用maven编译我的项目我标记了以下错误:

error: type mismatch;

[INFO]  required: **scala.actors.Actor**
[INFO]     Auctioneer !? AddListener(**this**, this.itemId) match {
[INFO]                               ^

error: type mismatch;

[INFO]  required: **scala.actors.Actor**
[INFO]     Auctioneer ! RemoveListener(**this**, this.itemId)
[INFO]                                 ^

文件是:

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)
    Noop

  }


  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")

  }


}

任何人都可以告诉我我错过了或者我做错了

我在2.7.3版中编译了这个项目并且没有问题

请帮忙!!!

2 个答案:

答案 0 :(得分:3)

Lift的演员不再是Scala Actors。 可能是他们进行互操作的一种方式,但我建议首先尝试更改所有演员,以便他们成为举动演员。

答案 1 :(得分:1)

您可以在同一个项目中使用Scala Actors和Lift Actors,但不能将它们替换为彼此。他们使用完全不同的Actor系统实现,因此就我所知,他们不能互相发送消息。

在Lift项目中,我通常会将LiftActors用于我的单身,名为actor,它们将显式接收发送给它的消息。为了便于阅读,我将使用Scala actor来执行后台任务,例如记录写入数据库:

actor { mapper.save }