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

发布于 2024-09-28 01:14:15 字数 2903 浏览 4 评论 0原文

正在使用 scala 版本 2.8.0 和 lift 版本 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 中没有问题,

请帮忙!!!

Greetings

I'm using the scala version 2.8.0 and version 2.1 of lift to compile my project with maven I mark the following error:

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]                                 ^

the file is:

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

  }


}

anyone can tell me I'm missing or am I doing wrong

I had compiled this project in version 2.7.3 and had no problems

help please!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清秋悲枫 2024-10-05 01:14:15

Lift 的 Actor 不再是 Scala Actor。他们可能有一种互操作的方式,但我建议首先尝试更改所有演员,使他们成为 Lift Actor。

Lift's Actors are no longer Scala Actors. There may be a way for them to interoperate, but I'd suggest first trying to change all your actors so that they're Lift Actors.

‘画卷フ 2024-10-05 01:14:15

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

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

actor { mapper.save }

You can use Scala Actors and Lift Actors in the same project, but you cannot substitute them for one another. They use completely different implementations of the Actor system, so they cannot as far as I know send messages to each other.

In Lift projects I will typically use LiftActors for my singleton, named actors that will receive messages sent to it explicitly. For ease of readability, I'll use Scala actors for backgrounding tasks like logging writes to the database:

actor { mapper.save }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文