Howdy,
I think the problem is that you're mixing CRUDify into your Mapper class
definition, rather than the MetaMapper object definition.
Try:
class Category extends KeyedMapper[Long,Category] {
...
}
object CategoryMeta extends Category with KeyedMetaMapper
[Long,Category] with CRUDify[Long,Category] {
...
}
Thanks,
David
PS -- Please use 0.11-SNAPSHOT. It's the release candidate and I want to
make sure it gets as much testing as possible.
On Sat, Feb 21, 2009 at 4:22 AM, unyaunya <[email protected]> wrote:
>
> I got an compile error when calling validate method of Mapper trait.
> That is:
>
> [INFO] D:\dev\lift\sample\src\main\scala\mydomain\snippet
> \CategoryCrud.scala:48
> : error: erroneous reference to overloaded definition,
> [INFO] most specific definition is: method validate in trait Mapper of
> type => L
> ist[net.liftweb.http.FieldError],
> [INFO] yet alternative definition method validate in trait
> MetaMapper of type
> (jp.co.mss.model.Category)List[net.liftweb.http.FieldError]
> [INFO] is defined in a subclass
> [INFO] private def saveCategory(category: Category) =
> category.validate match
> {
> [INFO]
>
> The code that the error above occurred is below:
>
> <Category.scala>:
> object CategoryMeta extends Category with KeyedMetaMapper
> [Long,Category]{
> override def dbTableName = "category"
> override def fieldOrder = id :: parent :: name :: Nil
> }
> class Category extends KeyedMapper[Long,Category] with CRUDify
> [Long,Category]{
> def getSingleton = CategoryMeta // Metaオブジェクト
> def primaryKeyField = id // 主キーの設定
>
> object id extends MappedLongIndex(this)
> object parent extends MappedLongForeignKey(this, CategoryMeta) {
> override def asHtml = this.obj match {
> case Full(c) => Text(c.name.is)
> case Empty => Text("N/A")
> case Failure(msg, _, _) => Text(msg)
> }
> override def validSelectValues: Box[List[(Long, String)]] =
> Full(CategoryMeta.findAll().map(c => (c.id.is, c.name.is)))
> }
> object name extends MappedString(this, 128)
>
> }
>
> o
> <CategoryCrud.scala>:
> ...
> private def saveCategory(category: Category) = category.validate
> match {
> case Nil => category.save(); redirectTo("/category/index.html")
> case x => error(x.toString); selectedCategory(Full(category))
> }
>
>
> Other method such as "save" and "delete_!" result in the same error
>
> I think that "category" is an instance of Mapper trait, and not an
> instance of MetaMapper.
> If an instance of Mapper implicitly wolud be converted to MetaMapper
> and that occurred the error, every people using Mapper would encounter
> the same situation
>
> So, I'm wondering why this error happens. and I think I must have made
> some mistake.
>
> I use lift0.10 and Scala2.7.3.
> Could anyone suggest?
>
> >
>
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---