Share Pastebin
Guest
Public paste!

djensen47

By: a guest | Mar 22nd, 2010 | Syntax: Scala | Size: 1.24 KB | Hits: 106 | Expires: Never
Copy text to clipboard
  1. package com.pocketchangeapp.model
  2. // Import all of the mapper classes
  3.  
  4. import _root_.net.liftweb.mapper._
  5. // Create a User class extending the Mapper base class
  6. // MegaProtoUser, which provides default fields and methods
  7. // for a site user.
  8. class User extends MegaProtoUser[User] {
  9.   def getSingleton = User // reference to the companion object below
  10.   def allAccounts : List[Account] =
  11.     Account.findAll(By(Account.owner, this.id))
  12. }
  13.  
  14. // Create a "companion object" to the User class (above).
  15. // The companion object is a "singleton" object that shares the same
  16. // name as its companion class. It provides global (i.e. non-instance)
  17. // methods and fields, such as find, dbTableName, dbIndexes, etc.
  18. // For more, see the Scala documentation on singleton objects
  19. object User extends User with MetaMegaProtoUser[User] {
  20.   override def dbTableName = "users" // define the DB table name
  21.  
  22.   // Provide our own login page template.
  23.   override def loginXhtml =
  24.     <lift:surround with="default" at="content">
  25.       { super.loginXhtml }
  26.     </lift:surround>
  27.  
  28.   // Provide our own signup page template.
  29.   override def signupXhtml(user: User) =
  30.     <lift:surround with="default" at="content">
  31.       { super.signupXhtml(user) }
  32.     </lift:surround>
  33. }