In the interest of sharing ideas with the larger Lift community, I
found myself creating many different mapper classes to model a
hierarchy of entities best viewed in a tree, such as roles, tags and
navigation links. To reduce code duplication, and to try to better
understand Mapper classes, I went about creating a tree item mapper
trait and its companion meta mapper object.

I defined the item mapper as:

trait MegaTreeItem[T <: MegaTreeItem[T]] extends KeyedMapper[Long, T]
{ .. }

which has a parent (owner) metamapper object of type T, an itemName
MappedString and some useful, though not an exhaustive number of
functions.

and the meta mapper

trait MetaMegaTreeItem[ModelType <: MegaTreeItem[ModelType]] extends
KeyedMetaMapper[Long, ModelType] {..}

which contains menu Locs and template/snippet functions for list and
tree table display.


So, creating a tag mapper is a cinch:

object Tag extends Tag with MetaMegaTreeItem[Tag] {
}


class Tag extends MegaTreeItem[Tag]{
  def getSingleton = Tag
  def owner = Tag
}

I'm still mystified about the workings of Mappers and MetaMappers and
why creating new mapper traits has to be so wordy (maybe not, if I
understood better), but this does do the job.

You can see the code and all of this actually functioning (Yeah!), by
grabbing it on github, at
 http://github.com/glennSilverman/democritus

Disclaimer: I could not get the tree table to work in IE 8. I think
it's a problem with the JQuery javascript. It works
great in Firefox, however.

Glenn
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to