Wow, that was fast :)

Here's my Boot.scala:

package bootstrap.liftweb

import _root_.net.liftweb.util._
import _root_.net.liftweb.http._
import _root_.net.liftweb.sitemap._
import _root_.net.liftweb.sitemap.Loc._
import Helpers._
import _root_.net.liftweb.mapper.{DB, ConnectionManager, Schemifier,
DefaultConnectionIdentifier, ConnectionIdentifier}
import _root_.java.sql.{Connection, DriverManager}
import _root_.lift.workshop.model._
import _root_.javax.servlet.http.{HttpServletRequest}

/**
  * A class that's instantiated early and run.  It allows the
application
  * to modify lift's environment
  */
class Boot {
  def boot {
    if (!DB.jndiJdbcConnAvailable_?)
      DB.defineConnectionManager(DefaultConnectionIdentifier,
DBVendor)

    // where to search snippet
    LiftRules.addToPackages("lift.workshop")
    Schemifier.schemify(true, Log.infoF _, User, ToDo)

    // Build SiteMap
    val entries = Menu(Loc("Home", List("index"), "Home")) ::
User.sitemap
    LiftRules.setSiteMap(SiteMap(entries:_*))

    /*
     * Show the spinny image when an Ajax call starts
     */
    LiftRules.ajaxStart =
      Full(() => LiftRules.jsArtifacts.show("ajax-loader").cmd)

    /*
     * Make the spinny image go away when it ends
     */
    LiftRules.ajaxEnd =
      Full(() => LiftRules.jsArtifacts.hide("ajax-loader").cmd)

    LiftRules.early.append(makeUtf8)

    S.addAround(DB.buildLoanWrapper)
  }

  /**
   * Force the request to be UTF-8
   */
  private def makeUtf8(req: HttpServletRequest) {
    req.setCharacterEncoding("UTF-8")
  }

}

/**
* Database connection calculation
*/
object DBVendor extends ConnectionManager {
  private var pool: List[Connection] = Nil
  private var poolSize = 0
  private val maxPoolSize = 4

  private def createOne: Box[Connection] = try {
    val driverName: String = Props.get("db.driver") openOr
    "org.apache.derby.jdbc.EmbeddedDriver"

    val dbUrl: String = Props.get("db.url") openOr
    "jdbc:derby:lift_example;create=true"

    Class.forName(driverName)

    val dm = (Props.get("db.user"), Props.get("db.password")) match {
      case (Full(user), Full(pwd)) =>
        DriverManager.getConnection(dbUrl, user, pwd)

      case _ => DriverManager.getConnection(dbUrl)
    }

    Full(dm)
  } catch {
    case e: Exception => e.printStackTrace; Empty
  }

  def newConnection(name: ConnectionIdentifier): Box[Connection] =
    synchronized {
      pool match {
        case Nil if poolSize < maxPoolSize =>
          val ret = createOne
        poolSize = poolSize + 1
        ret.foreach(c => pool = c :: pool)
        ret

        case Nil => wait(1000L); newConnection(name)
        case x :: xs => try {
          x.setAutoCommit(false)
          Full(x)
        } catch {
          case e => try {
            pool = xs
            poolSize = poolSize - 1
            x.close
            newConnection(name)
          } catch {
            case e => newConnection(name)
          }
        }
      }
    }

  def releaseConnection(conn: Connection): Unit = synchronized {
    pool = conn :: pool
    notify
  }
}


Thanks in advance

Haim

On Feb 22, 1:37 am, David Pollak <[email protected]>
wrote:
> Haim,
>
> Please post your Boot.scala file as well.
>
> Thanks,
>
> David
>
> On Sat, Feb 21, 2009 at 3:21 PM, babysnakes <[email protected]>wrote:
>
>
>
>
>
> > Hi
>
> > I'm trying to run the starting guide with version 0.10. When I got to
> > the ToDo section (2.11), I got the error above. The page renders all
> > the <todo:...> tags instead of replacing them with the 'toForm'
> > method.
>
> > Here is my relevant files:
>
> >  TD.scala
> > =======
> > package lift.workshop.snippet
>
> > import lift.workshop._
> > import model._
>
> > import net.liftweb._
> > import http._
> > import SHtml._
> > import S._
>
> > import js._
> > import JsCmds._
>
> > import mapper._
> > import util._
> > import Helpers._
>
> > import scala.xml.{NodeSeq, Text}
>
> > class TD {
> >  def add(form: NodeSeq) {
> >    val todo = ToDo.create.owner(User.currentUser)
>
> >    def checkAndSave(): Unit =
> >      todo.validate match {
> >        case Nil => todo.save; S.notice("Added " + todo.desc)
> >        case xs => S.error(xs); S.mapSnippet("TD.add", doBind)
> >      }
>
> >    def doBind(form: NodeSeq) =
> >      bind("todo", form,
> >        "priority" -> todo.priority.toForm,
> >        "desc" -> todo.desc.toForm,
> >        "submit" -> submit("New", checkAndSave))
>
> >    doBind(form)
> >  }
> > }
>
> > index.html
> > ========
> > <lift:surround with="default" at="content">
> >    <lift:Util.out>Please
> >        <lift:menu.item name="Login">Log In</lift:menu.item>
> >    </lift:Util.out>
> >    <lift:Util.in>
> >        <lift:TD.add form="post">
> >            <table>
> >                <tr>
> >                    <td>Description:</td>
> >                    <td><todo:desc>To Do</todo:desc></td>
> >                </tr>
> >                <tr>
> >                    <td>Priority:</td>
> >                    <td><todo:priority>
> >                        <select><option>1</option></select>
> >                    </todo:priority></td>
> >                </tr>
> >                <tr>
> >                    <td>&nbsp;</td>
> >                    <td>
> >                        <todo:submit>
> >                            <button>New</button>
> >                        </todo:submit>
> >                    </td>
> >                </tr>
> >            </table>
> >        </lift:TD.add>
> >    </lift:Util.in>
> > </lift:surround>
>
> > = = = = = = = = = = = = = = =
>
> > Am I missing something?
>
> > Thanks in advance
> > --
> > Haim
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Git some:http://github.com/dpp

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