0
votes

User.scala

import net.liftweb.record.{ MegaProtoUser, MetaMegaProtoUser }
import net.liftweb.squerylrecord.RecordTypeMode._
import net.liftweb.common._
import net.liftweb.util.FieldError
import net.liftweb.http.S

class User extends MegaProtoUser[User] {

  def meta = User

  protected def valUnique(errorMsg: => String)(email: String): List[FieldError] = {
    List[FieldError]()
  }

}

/**
 * The singleton that has methods for accessing the database
 */
object User extends User with MetaMegaProtoUser[User] {

  override def basePath = "profile" :: Nil

  override def signupFields = email :: password :: Nil

  override def signupXhtml(user: TheUserType) = {
    (<form method="post" action={ S.uri }><table>
                                            <tr><td colspan="2">{ S.??("sign.up") }</td></tr>
                                            { localForm(user, false, signupFields) }
                                            <tr><td>&nbsp;</td><td><user:submit class="btn btn-primary" /></td></tr>
                                          </table></form>)
  }

  override def screenWrap = Full(<lift:surround with="default" at="content">
                                   <lift:bind/>
                                 </lift:surround>)

  // redefine login form for nice formatting
  override def loginXhtml =
    <form method="post" action={ S.uri }>
      <lift:msg show="All"/>
      <div style="margin-bottom: 5px; margin-left: 5px;">
        <strong>
          { S.??("log.in") }
        </strong>
      </div>
      <div style="float: left; line-height: 2.5em;margin-left: 5px; margin-right: 20px;">
        { S.??("email.address") }<br/>{ S.??("password") }<br/>
        <a href={ lostPasswordPath.mkString("/", "/", "") }>
          { S.??("recover.password") }
        </a>
      </div>
      <div style="line-height: 2.5em;">
        <user:email/>
        <br/>
        <user:password/>
        <br/>
        <user:submit class="btn btn-primary"/>
      </div>
    </form>

  protected def userFromStringId(id: String): Box[User] = from(PPSchema.users)(u =>
    where(u.id === id.toLong)
      select (u)).headOption

  protected def findUserByUserName(email: String): Box[User] = from(PPSchema.users)(u =>
    where(u.email === email)
      select (u)).headOption

  protected def findUserByUniqueId(id: String): Box[User] = userFromStringId(id)
}

i got it.add below code in class User.

override def saveTheRecord() : Box[User] = {
    val u = User.createRecord.email(email.is).password(password.is).firstName(firstName.is).lastName(lastName.is).validated(validated.is).superUser(superUser.is)

    Full(PPSchema.users.insert(u))
  }

error message is below:

Message: java.util.prefs.BackingStoreException: Raw Records don't save themselves net.liftweb.record.Record$class.saveTheRecord(Record.scala:89) com.posplus.model.User.saveTheRecord(User.scala:17) net.liftweb.record.MetaMegaProtoUser$MyUserBridge.save(ProtoUser.scala:294) net.liftweb.proto.ProtoUser$class.actionsAfterSignup(ProtoUser.scala:696) com.posplus.model.User$.actionsAfterSignup(User.scala:32) net.liftweb.proto.ProtoUser$class.testSignup$1(ProtoUser.scala:737) net.liftweb.proto.ProtoUser$$anonfun$innerSignup$1$1.apply(ProtoUser.scala:745) net.liftweb.proto.ProtoUser$$anonfun$innerSignup$1$1.apply(ProtoUser.scala:745) net.liftweb.http.S$NFuncHolder$$anonfun$apply$5.apply(S.scala:190) net.liftweb.http.S$NFuncHolder$$anonfun$apply$5.apply(S.scala:190) scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194) scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194) scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59) scala.collection.immutable.List.foreach(List.scala:45) scala.collection.TraversableLike$class.map(TraversableLike.scala:194) scala.collection.immutable.List.map(List.scala:45) net.liftweb.http.S$NFuncHolder.apply(S.scala:190) net.liftweb.http.S$ProxyFuncHolder.apply(S.scala:115) net.liftweb.http.LiftSession$$anonfun$buildFunc$1$2.apply(LiftSession.scala:651) net.liftweb.http.LiftSession$$anonfun$16$$anonfun$apply$39.apply(LiftSession.scala:667) net.liftweb.http.LiftSession$$anonfun$16$$anonfun$apply$39.apply(LiftSession.scala:667) scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194) scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194) scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59) scala.collection.immutable.List.foreach(List.scala:45) scala.collection.TraversableLike$class.map(TraversableLike.scala:194) scala.collection.immutable.List.map(List.scala:45) net.liftweb.http.LiftSession$$anonfun$16.apply(LiftSession.scala:667) net.liftweb.http.LiftSession$$anonfun$16.apply(LiftSession.scala:656) scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:200) scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:200) scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59) scala.collection.immutable.List.foreach(List.scala:45) scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:200) scala.collection.immutable.List.flatMap(List.scala:45) net.liftweb.http.LiftSession.runParams(LiftSession.scala:655) net.liftweb.http.LiftSession.processRequest(LiftSession.scala:1074) net.liftweb.http.LiftServlet.net$liftweb$http$LiftServlet$$dispatchStatefulRequest(LiftServlet.scala:414) net.liftweb.http.LiftServlet$$anonfun$doSession$1$1.apply(LiftServlet.scala:279) net.liftweb.http.LiftServlet$$anonfun$doSession$1$1.apply(LiftServlet.scala:279) net.liftweb.http.S$class.net$liftweb$http$S$$wrapQuery(S.scala:1376) net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_nest2InnerInit$1$$anonfun$apply$34.apply(S.scala:1524) net.liftweb.http.S$class.net$liftweb$http$S$$doAround(S.scala:1305) net.liftweb.http.S$$anonfun$net$liftweb$http$S$$doAround$1.apply(S.scala:1306) org.squeryl.dsl.QueryDsl$class._using(QueryDsl.scala:46) org.squeryl.dsl.QueryDsl$class._executeTransactionWithin(QueryDsl.scala:105) org.squeryl.dsl.QueryDsl$class.inTransaction(QueryDsl.scala:91) net.liftweb.squerylrecord.RecordTypeMode$.inTransaction(RecordTypeMode.scala:34) bootstrap.liftweb.Boot$$anon$1.apply(Boot.scala:58) net.liftweb.http.S$class.net$liftweb$http$S$$doAround(S.scala:1306) net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_nest2InnerInit$1.apply(S.scala:1522) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.S$class.net$liftweb$http$S$$_nest2InnerInit(S.scala:1521) net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1$$anonfun$apply$38$$anonfun$apply$39$$anonfun$apply$40$$anonfun$apply$41.apply(S.scala:1561) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.S$$anonfun$withReq$1.apply(S.scala:1571) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.S$class.withReq(S.scala:1570) net.liftweb.http.S$.withReq(S.scala:48) net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1$$anonfun$apply$38$$anonfun$apply$39$$anonfun$apply$40.apply(S.scala:1560) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1$$anonfun$apply$38$$anonfun$apply$39.apply(S.scala:1559) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1$$anonfun$apply$38.apply(S.scala:1558) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1.apply(S.scala:1557) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.S$class.net$liftweb$http$S$$_innerInit(S.scala:1556) net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_init$1$$anonfun$apply$44$$anonfun$apply$45$$anonfun$apply$46$$anonfun$apply$47$$anonfun$apply$48.apply(S.scala:1594) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_init$1$$anonfun$apply$44$$anonfun$apply$45$$anonfun$apply$46$$anonfun$apply$47.apply(S.scala:1592) net.liftweb.http.CoreRequestVarHandler$class.apply(Vars.scala:613) net.liftweb.http.RequestVarHandler$.apply(Vars.scala:515) net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_init$1$$anonfun$apply$44$$anonfun$apply$45$$anonfun$apply$46.apply(S.scala:1591) net.liftweb.http.CoreRequestVarHandler$class.apply(Vars.scala:613) net.liftweb.http.TransientRequestVarHandler$.apply(Vars.scala:528) net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_init$1$$anonfun$apply$44$$anonfun$apply$45.apply(S.scala:1590) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_init$1$$anonfun$apply$44.apply(S.scala:1589) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_init$1.apply(S.scala:1588) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.S$class.net$liftweb$http$S$$init(S.scala:1587) net.liftweb.http.S$class.init(S.scala:1190) net.liftweb.http.LiftServlet.doSession$1(LiftServlet.scala:278) net.liftweb.http.LiftServlet.doService(LiftServlet.scala:288) net.liftweb.http.LiftServlet$$anonfun$doIt$1$1.apply(LiftServlet.scala:132) net.liftweb.http.LiftServlet$$anonfun$doIt$1$1.apply(LiftServlet.scala:131) net.liftweb.util.TimeHelpers$class.calcTime(TimeHelpers.scala:344) net.liftweb.util.Helpers$.calcTime(Helpers.scala:34) net.liftweb.util.TimeHelpers$class.logTime(TimeHelpers.scala:363) net.liftweb.util.Helpers$.logTime(Helpers.scala:34) net.liftweb.http.LiftServlet.doIt$1(LiftServlet.scala:131) net.liftweb.http.LiftServlet.service(LiftServlet.scala:142) net.liftweb.http.provider.HTTPProvider$$anonfun$service$2$$anonfun$apply$mcV$sp$1$$anonfun$apply$mcV$sp$2.apply$mcV$sp(HTTPProvider.scala:72) net.liftweb.http.provider.HTTPProvider$$anonfun$service$2$$anonfun$apply$mcV$sp$1$$anonfun$apply$mcV$sp$2.apply(HTTPProvider.scala:71) net.liftweb.http.provider.HTTPProvider$$anonfun$service$2$$anonfun$apply$mcV$sp$1$$anonfun$apply$mcV$sp$2.apply(HTTPProvider.scala:71) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.URLRewriter$.doWith(Req.scala:1253) net.liftweb.http.provider.HTTPProvider$$anonfun$service$2$$anonfun$apply$mcV$sp$1.apply$mcV$sp(HTTPProvider.scala:70) net.liftweb.http.provider.HTTPProvider$$anonfun$service$2$$anonfun$apply$mcV$sp$1.apply(HTTPProvider.scala:70) net.liftweb.http.provider.HTTPProvider$$anonfun$service$2$$anonfun$apply$mcV$sp$1.apply(HTTPProvider.scala:70) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.provider.HTTPProvider$$anonfun$service$2.apply$mcV$sp(HTTPProvider.scala:66) net.liftweb.http.provider.HTTPProvider$$anonfun$service$2.apply(HTTPProvider.scala:60) net.liftweb.http.provider.HTTPProvider$$anonfun$service$2.apply(HTTPProvider.scala:60) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.provider.HTTPProvider$class.service(HTTPProvider.scala:60) net.liftweb.http.LiftFilter.service(LiftServlet.scala:757) net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun$doFilter$1$$anonfun$apply$mcV$sp$1.apply$mcV$sp(ServletFilterProvider.scala:67) net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun$doFilter$1$$anonfun$apply$mcV$sp$1.apply(ServletFilterProvider.scala:62) net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun$doFilter$1$$anonfun$apply$mcV$sp$1.apply(ServletFilterProvider.scala:62) net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$16$$anonfun$apply$17$$anonfun$apply$18$$anonfun$apply$19.apply(Vars.scala:619) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$16$$anonfun$apply$17$$anonfun$apply$18.apply(Vars.scala:618) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$16$$anonfun$apply$17.apply(Vars.scala:617) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$16.apply(Vars.scala:616) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.CoreRequestVarHandler$class.apply(Vars.scala:615) net.liftweb.http.RequestVarHandler$.apply(Vars.scala:515) net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun$doFilter$1.apply(ServletFilterProvider.scala:61) net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun$doFilter$1.apply(ServletFilterProvider.scala:61) net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$16$$anonfun$apply$17$$anonfun$apply$18$$anonfun$apply$19.apply(Vars.scala:619) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$16$$anonfun$apply$17$$anonfun$apply$18.apply(Vars.scala:618) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$16$$anonfun$apply$17.apply(Vars.scala:617) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$16.apply(Vars.scala:616) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) net.liftweb.http.CoreRequestVarHandler$class.apply(Vars.scala:615) net.liftweb.http.provider.servlet.ServletFilterProvider$class.doFilter(ServletFilterProvider.scala:60) net.liftweb.http.LiftFilter.doFilter(LiftServlet.scala:757) org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1337) org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:486) org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119) org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:520) org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233) org.eclipse.jetty.server.handler.ContextHandler._doHandle(ContextHandler.java:973) org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java) org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:417) org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192) org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:907) org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250) org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110) org.eclipse.jetty.server.Server.handle(Server.java:346) org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:442) org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:941) org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:801) org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:224) org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51) org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586) org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44) org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598) org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533) java.lang.Thread.run(Thread.java:680)

1

1 Answers

2
votes

I'm afraid that ProtoUser doesn't work with SquerylRecord right now.