Owen
Owen

Reputation: 7098

Scalatra Databinding

I'm playing with command model binding and I looked at the example github project and I have issues when using the dependency:

  "org.scalatra" % "scalatra-data-binding" % "2.2.0-RC1"

Taking the example project code i.e.

abstract class TodosCommand[S](implicit mf: Manifest[S]) extends ModelCommand[S] with ParamsOnlyCommand
class CreateTodoCommand extends TodosCommand[Todo] {
  val name: Field[String] = asType[String]("name").notBlank.minLength(3)
}
case class Todo(id: Integer, name: String, done: Boolean = false)  

I am unable to compile when I use the command[CreateTodoCommand] method from the CommandSupport trait i.e.

scala: type arguments [au.com.xxx.sapi.seo.CreateTodoCommand] do not conform to method command's type parameter bounds [T <: SeoServlet.this.CommandType]
    val cmd = command[CreateTodoCommand]
                     ^

I'm not that clued up with Scala but I would assume that as ParamsOnlyCommand extends Command and there is this line in the command support trait, then there should be no issues:

  type CommandType <: org.scalatra.databinding.Command

Any ideas why I am getting this issue?

Cheers, Chris.

Upvotes: 1

Views: 385

Answers (2)

Phili
Phili

Reputation: 1

In Scalatra 2.2.1, "org.scalatra" %% "scalatra-commands" % "2.2.0" I have no issues. but I don't know scalatra-data-binding is also standalone.

Upvotes: 0

futurechimp
futurechimp

Reputation: 554

It's very likely that the reason you're having problems is that we're still linking to an ancient example version, for which the docs no longer apply. I thought I'd caught all of the example projects in the docs and moved them into https://github.com/scalatra/scalatra-website-examples, but apparently I missed this one. Sorry for the hassle!

I'll see if I can fix this today sometime, and provide a compiling example. In the meantime, you might try updating all your Scalatra-related dependencies to the 2.2.0 release - and see if that fixes anything straight away.

The latest stable release of Scalatra is currently 2.2.1, but you'll need to be careful around commands as I remember @casualjim saying that he'd changed the way things worked to some extent between 2.2.0 and 2.2.1.

Upvotes: 1

Related Questions