I'm not sure if this will work as intended, but I'm trying.

Here's a Company class(and its object) that inherits an Address trait:

object Company extends Company with LongKeyedMetaMapper[Company]{

  override def fieldOrder = List(name, line1.asInstanceOf,
                                 line2.asInstanceOf,
city.asInstanceOf, state.asInstanceOf, postalCode.asInstanceOf)
}

class Company extends LongKeyedMapper[Company] with Address[Company]
with IdPK  {

  def getSingleton = Company
  object name extends MappedString(this, 100)

}

Address is defined as follows:

trait Address[OwnerType <: LongKeyedMapper[OwnerType]] {
  def owner = this.asInstanceOf

  object line1 extends MappedString(owner, 100){
    override def displayName = "Address1"
  }

  object line2 extends MappedString(owner, 50){
    override def displayName = "Address2"
  }

  object city extends MappedString(owner, 50){
    override def displayName = "City"
  }

  object state extends MappedState(owner) {
    override def displayName = "State"
  }

  object mc extends MappedCountry[OwnerType](owner){
    override def dbColumnName = "country_enum"
    override def defaultValue = Countries.USA
  }

  object postalCode extends MappedPostalCode[OwnerType](owner, mc)

}

Glenn Silverman


On Apr 1, 2:21 am, Tobias Daub <[email protected]> wrote:
> Hi There,
>
> I'm new to Scala and Lift and still feeling a little bit lost.
>
> In case of the ToDo example from the Getting started guide: Would it be
> possible to make a more specialized version of a ToDo item that inherits
> from the existing one?
>
> This is more a general question aboutinheritancefrom Lift models,
> because I've to design some more complexclasshierarchy, where its
> really necessary to have "stupid" classes that can be specialized later on.
>
> Apply the same rules aboutinheritance, traits, etc. to Lift models,
> too. Can I do all the stuff that I can do with "normal" classes?
>
> Thanks alot!
> Tobias

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to