On Mon, Jul 6, 2009 at 12:23 PM, Jeppe Nejsum Madsen<[email protected]> wrote:
> Hi,
>
> What is the best way to copy values from one mapped object to another
> (of the same type). The code below seems to work but I was wondering if
> there's a better way?
And just for future reference, the previous example didn't actually
work, but this does:
case Full(existing) => {
existing.getSingleton.mappedFields.foreach (f =>
(existing.fieldByName(f.name), v.fieldByName(f.name)) match {
case (Full(dest), Full(src)) if (!dest.dbPrimaryKey_?) =>
val destField = dest.asInstanceOf[MappedField[Any, Vehicle]]
val srcValue = src.asInstanceOf[MappedField[Any, Vehicle]].is
destField.setFromAny(srcValue);
case _ =>
}
)
This is what you get for not writing proper test cases :-) (I'm still
fighting the problem of writing unit tests for model classes.....)
/Jeppe
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---