I had the same problem with a User object that extends
MetaMegaProtoUser[User], which has the MetaMapper trait as well.
The afterSave you wish to override is defined in the trait
net.liftweb.mapper.MetaMapper as def afterSave: List[(A) => Any] =
Nil.
You can add an operation to afterSave like this:
class X extends LongKeyedMapper[X] with IdPK {
def getSingleton = X
def myAfterSaveOperation(obj: X): Unit = {
println("hi!")
}
def myOtherAfterSaveOperation(obj: X): Unit = {
println("hi again!")
}
override def afterSave = myAfterSaveOperation _ ::
myOtherAfterSaveOperation _ :: Nil
/* Equal to: override def afterSave = List(myAfterSaveOperation
_, myOtherAfterSaveOperation _) */
...
}
object X extends X with LongKeyedMetaMapper[X] {
...
}
Here the underscore after myAfterSaveOperation makes it a partially
applied function.
This is similar to the way validations are added to MetaMapper
classes, as decribed in listing 6.38 in the Lift book (http://
groups.google.com/group/the-lift-book).
MetaMapper does not implement LifecycleCallbacks, that trait is indeed
used in MappedFields.
--
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.