Created
August 15, 2012 21:08
-
-
Save ripla/3363699 to your computer and use it in GitHub Desktop.
Scaladin registration example 1-1: basic application with a Mongo connection.
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
import vaadin.scala._ | |
import com.mongodb.casbah.Imports._ | |
import com.novus.salat.grater | |
import com.novus.salat.global._ | |
import scala.util.Random | |
import scala.reflect.BeanProperty | |
class MongoExample extends Application("Mongo & Vaadin, tied together with Scala") { | |
val registrations: MongoCollection = MongoConnection()("vaadin-scala-mongo-example")("registrations") | |
def mapRegistrations: List[Registration] = registrations.map(grater[Registration].asObject(_)).toList | |
def saveRegistration(registration: Registration): Unit = registrations += grater[Registration].asDBObject(registration) | |
override val main: ComponentContainer = new VerticalLayout | |
} | |
case class Registration( | |
@BeanProperty var username: String = "username" + Random.nextInt, | |
@BeanProperty var password: String = "", | |
@BeanProperty var realName: String = "Joe Tester") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment