我已经实现了一个基于 mongodb-record 的模型,我正在尝试编写表单以将数据(事件记录)存储到数据库中。
要存储的对象的片段是:
class eventSnippet extends StatefulSnippet with PaginatorSnippet[event] {
var dispatch: DispatchIt = {
case "editForm" => editForm _
}
var editingevent = event.createRecord
def editForm(xhtml: NodeSeq): NodeSeq = {
("#editName" #> editingevent.title.toForm &
"#editDescription" #> editingevent.description.toForm &
"#editDT" #> editingevent.date_time.toForm &
"#editCat" #> editingevent.category.toForm &
"#editPrivacy" #> editingevent.privacy.toForm &
"type=submit" #> SHtml.submit(?("Save"), () => save )).apply(xhtml)
}
def save = {
editingevent.save
redirectToHome
}}
错误是:
class eventSnippet needs to be abstract, since:
[error] method page in trait Paginator of type => Seq[code.model.event] is not defined
[error] method count in trait Paginator of type => Long is not defined
当我将类更改为抽象时,它可以编译,但在浏览器上出现错误:
Message: java.lang.InstantiationException
sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:30)
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
我正在使用 sbt 0.7.5 和 Scala 2.9.1。