-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
844 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
This repository contains tempaltes for Lift project. | ||
|
||
These templates offer a starting point for your Lift-based project. | ||
|
||
If you want to start with Scala 2.8.1, use the templates in the scala_28 directory | ||
|
||
If you want to start with Scala 2.9.0-1, use the templates in the scala_29 directory | ||
|
||
Questions, feedback, etc. please join the conversation at https://groups.google.com/forum/#!forum/liftweb | ||
A test to show ReqestVar's behaving differently when they contain a String vs when they contain a Mapper object. | ||
|
||
1) Go to http://localhost:8080/reqvareventlist | ||
2) click edit | ||
3) click submit | ||
4) enjoy the NPE!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,214 @@ | ||
// set the name of the project | ||
name := "ReqVarTest" | ||
|
||
version := "0.1.0" | ||
|
||
scalaVersion := "2.9.1" | ||
|
||
// seq(WebPlugin.webSettings: _*) | ||
seq(webSettings :_*) | ||
|
||
// jettyContext := "/mediahub" | ||
// jettyContext in container.Configuration = "/mediahub" | ||
|
||
organization := "damianhelme" | ||
|
||
// for jrebel | ||
// jettyScanDirs := Nil | ||
scanDirectories in Compile := Nil | ||
|
||
// add a test dependency on ScalaCheck | ||
// libraryDependencies += "org.scala-tools.testing" %% "scalacheck" % "1.8" % "test" | ||
libraryDependencies ++= { | ||
val liftVersion = "2.4-M4" | ||
//val liftVersion = "2.3" | ||
Seq( | ||
"net.liftweb" %% "lift-webkit" % liftVersion % "compile", | ||
"net.liftweb" %% "lift-mapper" % liftVersion % "compile", | ||
"net.liftweb" %% "lift-record" % liftVersion % "compile", | ||
"net.liftweb" %% "lift-wizard" % liftVersion % "compile", | ||
"net.liftweb" %% "lift-widgets" % liftVersion % "compile", | ||
"ch.qos.logback" % "logback-classic" % "0.9.26" % "compile", | ||
"com.h2database" % "h2" % "1.2.138", | ||
"mysql" % "mysql-connector-java" % "5.1.16", | ||
"javax.servlet" % "servlet-api" % "2.5" % "provided", | ||
// "org.mortbay.jetty" % "jetty" % "6.1.26" % "test,jetty", | ||
"org.mortbay.jetty" % "jetty" % "6.1.26" % "test,container", | ||
// "org.mortbay.jetty" % "jetty-plus" % "6.1.26" % "test,jetty", | ||
"org.mortbay.jetty" % "jetty-plus" % "6.1.26" % "test,container", | ||
// "org.eclipse.jetty" % "jetty-webapp" % "7.4.5.v20110725" % "compile,test->default" , | ||
"junit" % "junit" % "4.5" % "test", | ||
// "org.scala-tools.testing" %% "specs" % "1.6.9" % "test", | ||
"org.scalatest" %% "scalatest" % "1.6.1" % "test", | ||
// "org.scalatest" %% "scalatest" % "1.5.1" % "test", | ||
"org.scala-lang" % "scala-compiler" % "2.9.1" | ||
// "org.scala-lang" % "scala-compiler" % "2.9.1" | ||
// "eu.medsea.mimeutil" % "mime-util" % "2.1.3" | ||
) | ||
} | ||
|
||
|
||
scalacOptions ++= Seq("-unchecked", "-deprecation") | ||
|
||
mainClass := Some("RunWebApp") | ||
|
||
// https://groups.google.com/forum/?hl=en#!activity/liftweb/Um5ghzYMDUoJ/liftweb/DDTzzxRbCNU/qEo0lIbTv4kJ | ||
// needed for javaMail 1.4.4 | ||
resolvers += "Java.net Maven2 Repo" at "http://download.java.net/maven/2/" | ||
|
||
// jettyConfFiles <<= jettyConfFiles(_.copy(env = Some(file(".") / "src" / "test" / "resources" / "jetty.xml" asFile))) | ||
|
||
// needed to stop a clash between slf4j-log4j12 and logback-classic | ||
// ivyXML := <dependencies> | ||
// <dependency org="eu.medsea.mimeutil" name="mime-util" rev="2.1.3" > | ||
// <exclude module="slf4j-log4j12" /> | ||
// </dependency> | ||
// </dependencies> | ||
|
||
// add compile dependencies on some dispatch modules | ||
// libraryDependencies ++= Seq( | ||
// "net.databinder" %% "dispatch-meetup" % "0.7.8", | ||
// "net.databinder" %% "dispatch-twitter" % "0.7.8" | ||
// ) | ||
|
||
// Set a dependency based partially on a val. | ||
// { | ||
// val libosmVersion = "2.5.2-RC1" | ||
// libraryDependencies += "net.sf.travelingsales" % "osmlib" % libosmVersion from "http://downloads.sourceforge.net/project/travelingsales/libosm/"+libosmVersion+"/libosm-"+libosmVersion+".jar" | ||
// } | ||
|
||
// reduce the maximum number of errors shown by the Scala compiler | ||
// maxErrors := 20 | ||
|
||
// increase the time between polling for file changes when using continuous execution | ||
// pollInterval := 1000 | ||
|
||
// append several options to the list of options passed to the Java compiler | ||
// javacOptions ++= Seq("-source", "1.5", "-target", "1.5") | ||
|
||
// append -deprecation to the options passed to the Scala compiler | ||
// scalacOptions += "-deprecation" | ||
|
||
// define the statements initially evaluated when entering 'console', 'console-quick', or 'console-project' | ||
// initialCommands := """ | ||
// import System.{currentTimeMillis => now} | ||
// def time[T](f: => T): T = { | ||
// val start = now | ||
// try { f } finally { println("Elapsed: " + (now - start)/1000.0 + " s") } | ||
// } | ||
// """ | ||
|
||
// set the initial commands when entering 'console' only | ||
// initialCommands in console := "import damianhelme._" | ||
|
||
// set the main class for packaging the main jar | ||
// 'run' will still auto-detect and prompt | ||
// change Compile to Test to set it for the test jar | ||
// mainClass in (Compile, packageBin) := Some("myproject.MyMain") | ||
|
||
// set the main class for the main 'run' task | ||
// change Compile to Test to set it for 'test:run' | ||
// mainClass in (Compile, run) := Some("myproject.MyMain") | ||
|
||
// add <base>/input to the files that '~' triggers on | ||
// watchSources <+= baseDirectory map { _ / "input" } | ||
|
||
// add a maven-style repository | ||
// resolvers += "name" at "url" | ||
|
||
// add a sequence of maven-style repositories | ||
// resolvers ++= Seq("name" at "url") | ||
|
||
// define the repository to publish to | ||
// publishTo := Some("name" at "url") | ||
|
||
// set Ivy logging to be at the highest level | ||
// ivyLoggingLevel := UpdateLogging.Full | ||
|
||
// disable updating dynamic revisions (including -SNAPSHOT versions) | ||
// offline := true | ||
|
||
// set the prompt (for this build) to include the project id. | ||
// shellPrompt in ThisBuild := { state => Project.extract(state).currentRef.project + "> " } | ||
|
||
// set the prompt (for the current project) to include the username | ||
// shellPrompt := { state => System.getProperty("user.name") + "> " } | ||
|
||
// disable printing timing information, but still print [success] | ||
// showTiming := false | ||
|
||
// disable printing a message indicating the success or failure of running a task | ||
// showSuccess := false | ||
|
||
// change the format used for printing task completion time | ||
// timingFormat := { | ||
// import java.text.DateFormat | ||
// DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT) | ||
// } | ||
|
||
// disable using the Scala version in output paths and artifacts | ||
// crossPaths := false | ||
|
||
// fork a new JVM for 'run' and 'test:run' | ||
// fork := true | ||
|
||
// fork a new JVM for 'test:run', but not 'run' | ||
// fork in Test := true | ||
|
||
// add a JVM option to use when forking a JVM for 'run' | ||
// javaOptions += "-Xmx2G" | ||
|
||
// only use a single thread for building | ||
// parallelExecution := false | ||
|
||
// Execute tests in the current project serially | ||
// Tests from other projects may still run concurrently. | ||
// parallelExecution in Test := false | ||
|
||
// set the location of the JDK to use for compiling Java code. | ||
// if 'fork' is true, this is used for 'run' as well | ||
// javaHome := Some(file("/usr/lib/jvm/sun-jdk-1.6")) | ||
|
||
// Use Scala from a directory on the filesystem instead of retrieving from a repository | ||
// scalaHome := Some(file("/home/user/scala/trunk/")) | ||
|
||
// don't aggregate clean (See FullConfiguration for aggregation details) | ||
// aggregate in clean := false | ||
|
||
// only show warnings and errors on the screen for compilations. | ||
// this applies to both test:compile and compile and is Info by default | ||
// logLevel in compile := Level.Info | ||
|
||
// only show warnings and errors on the screen for all tasks (the default is Info) | ||
// individual tasks can then be more verbose using the previous setting | ||
logLevel := Level.Info | ||
|
||
// only store messages at info and above (the default is Debug) | ||
// this is the logging level for replaying logging with 'last' | ||
// persistLogLevel := Level.Debug | ||
|
||
// only show 10 lines of stack traces | ||
// traceLevel := 10 | ||
|
||
// only show stack traces up to the first sbt stack frame | ||
// traceLevel := 0 | ||
|
||
// add SWT to the unmanaged classpath | ||
// unmanagedJars in Compile += file("/usr/share/java/swt.jar") | ||
|
||
// publish test jar, sources, and docs | ||
// publishArtifact in Test := true | ||
|
||
// disable publishing of main docs | ||
// publishArtifact in (Compile, packageDoc) := false | ||
|
||
// change the classifier for the docs artifact | ||
// artifactClassifier in packageDoc := Some("doc") | ||
|
||
// Copy all managed dependencies to <build-root>/lib_managed/ | ||
// This is essentially a project-local cache and is different | ||
// from the lib_managed/ in sbt 0.7.x. There is only one | ||
// lib_managed/ in the build root (not per-project). | ||
// retrieveManaged := true | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
java -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Xmx512M -Xss2M -jar `dirname $0`/sbt-launch-0.11.0.jar "$@" |
Binary file not shown.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package bootstrap.liftweb | ||
|
||
import net.liftweb._ | ||
import util._ | ||
import Helpers._ | ||
|
||
import common._ | ||
import http._ | ||
import sitemap._ | ||
import Loc._ | ||
import mapper._ | ||
|
||
import code.model._ | ||
|
||
|
||
/** | ||
* A class that's instantiated early and run. It allows the application | ||
* to modify lift's environment | ||
*/ | ||
class Boot { | ||
def boot { | ||
if (!DB.jndiJdbcConnAvailable_?) { | ||
val vendor = | ||
new StandardDBVendor(Props.get("db.driver") openOr "org.h2.Driver", | ||
Props.get("db.url") openOr | ||
"jdbc:h2:lift_proto.db;AUTO_SERVER=TRUE", | ||
Props.get("db.user"), Props.get("db.password")) | ||
|
||
LiftRules.unloadHooks.append(vendor.closeAllConnections_! _) | ||
|
||
DB.defineConnectionManager(DefaultConnectionIdentifier, vendor) | ||
} | ||
|
||
// Use Lift's Mapper ORM to populate the database | ||
// you don't need to use Mapper to use Lift... use | ||
// any ORM you want | ||
import code.snippet.MyEvent | ||
Schemifier.schemify(true, Schemifier.infoF _, User, MyEvent) | ||
|
||
// where to search snippet | ||
LiftRules.addToPackages("code") | ||
|
||
// Build SiteMap | ||
def sitemap = SiteMap( | ||
Menu.i("Home") / "index", | ||
// >> User.AddUserMenusAfter, // the simple way to declare a menu | ||
Menu("ReqVar String Edit") / "reqvarstringedit" >> Hidden, | ||
Menu("ReqVar String List") / "reqvarstringlist", | ||
Menu("ReqVar Event Edit") / "reqvareventedit" >> Hidden, | ||
Menu("ReqVar Event List") / "reqvareventlist" | ||
// more complex because this menu allows anything in the | ||
// /static path to be visible | ||
//Menu(Loc("Static", Link(List("static"), true, "/static/index"), "Static Content")) | ||
) | ||
|
||
//def sitemapMutators = User.sitemapMutator | ||
|
||
// set the sitemap. Note if you don't want access control for | ||
// each page, just comment this line out. | ||
//LiftRules.setSiteMapFunc(() => sitemapMutators(sitemap)) | ||
LiftRules.setSiteMap(sitemap) | ||
|
||
|
||
// Use jQuery 1.4 | ||
LiftRules.jsArtifacts = net.liftweb.http.js.jquery.JQuery14Artifacts | ||
|
||
//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) | ||
|
||
// Force the request to be UTF-8 | ||
LiftRules.early.append(_.setCharacterEncoding("UTF-8")) | ||
|
||
// What is the function to test if a user is logged in? | ||
LiftRules.loggedInTest = Full(() => User.loggedIn_?) | ||
|
||
// Use HTML5 for rendering | ||
LiftRules.htmlProperties.default.set((r: Req) => | ||
new Html5Properties(r.userAgent)) | ||
|
||
// Make a transaction span the whole HTTP request | ||
S.addAround(DB.buildLoanWrapper) | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package code | ||
package lib | ||
|
||
import net.liftweb._ | ||
import http._ | ||
import util._ | ||
import common._ | ||
import java.util.Date | ||
|
||
/** | ||
* A factory for generating new instances of Date. You can create | ||
* factories for each kind of thing you want to vend in your application. | ||
* An example is a payment gateway. You can change the default implementation, | ||
* or override the default implementation on a session, request or current call | ||
* stack basis. | ||
*/ | ||
object DependencyFactory extends Factory { | ||
implicit object time extends FactoryMaker(Helpers.now _) | ||
|
||
/** | ||
* objects in Scala are lazily created. The init() | ||
* method creates a List of all the objects. This | ||
* results in all the objects getting initialized and | ||
* registering their types with the dependency injector | ||
*/ | ||
private def init() { | ||
List(time) | ||
} | ||
init() | ||
} | ||
|
||
/* | ||
/** | ||
* Examples of changing the implementation | ||
*/ | ||
sealed abstract class Changer { | ||
def changeDefaultImplementation() { | ||
DependencyFactory.time.default.set(() => new Date()) | ||
} | ||
def changeSessionImplementation() { | ||
DependencyFactory.time.session.set(() => new Date()) | ||
} | ||
def changeRequestImplementation() { | ||
DependencyFactory.time.request.set(() => new Date()) | ||
} | ||
def changeJustForCall(d: Date) { | ||
DependencyFactory.time.doWith(d) { | ||
// perform some calculations here | ||
} | ||
} | ||
} | ||
*/ |
Oops, something went wrong.