本文整理汇总了Scala中play.api.data.Forms.text类的典型用法代码示例。如果您正苦于以下问题:Scala text类的具体用法?Scala text怎么用?Scala text使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了text类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: MenuPerDayPerPersonForm
//设置package包名称以及导入依赖的类
package lunatech.lunchplanner.viewModels
import java.util.UUID
import play.api.data.Form
import play.api.data.Forms.{ mapping, text, _ }
import play.api.data.format.Formats._
import play.api.libs.json.{ Json, OFormat }
case class MenuPerDayPerPersonForm(
menuPerDayUuid: List[UUID],
menuDate: List[String]
)
object MenuPerDayPerPersonForm {
implicit val menuPerDayPerPersonFormFormat: OFormat[MenuPerDayPerPersonForm] = Json.format[MenuPerDayPerPersonForm]
val menuPerDayPerPersonForm = Form(
mapping(
"menuPerDayUuid" -> list(of[UUID]),
"menuDate" -> list(text)
)(MenuPerDayPerPersonForm.apply)(MenuPerDayPerPersonForm.unapply)
)
}
开发者ID:lunatech-labs,项目名称:lunatech-lunch-planner,代码行数:25,代码来源:MenuPerDayPerPersonForm.scala
示例2: HomeController
//设置package包名称以及导入依赖的类
package controllers
import javax.inject._
import akka.actor.{ActorSystem, _}
import dao.CatDAO
import models._
import play.api.cache.CacheApi
import play.api.data.Form
import play.api.data.Forms.{mapping, text}
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.api.libs.json.Json
import play.api.mvc._
@Singleton
class HomeController @Inject()(implicit system: ActorSystem, catDao: CatDAO, cache: CacheApi) extends Controller {
def index = Action.async {
val actorId = cache.get[String]("actor-id_1").get
println(actorId)
val client = system.actorSelection(actorId)
client ! Json.toJson(EventB("MessageB"))
catDao.all().map {
cats => Ok(views.html.index(cats))
}
}
def insertCat = Action.async { implicit request =>
val cat: Cat = catForm.bindFromRequest.get
catDao.insert(cat).map(_ => Redirect(routes.HomeController.index))
}
def ws = Action { request => Ok(views.html.ws()) }
val catForm = Form(
mapping(
"name" -> text(),
"color" -> text()
)(Cat.apply)(Cat.unapply)
)
}
开发者ID:koduki,项目名称:example-palyframework,代码行数:45,代码来源:HomeController.scala
示例3: ProfileForm
//设置package包名称以及导入依赖的类
package lunatech.lunchplanner.viewModels
import play.api.data.Form
import play.api.data.Forms.{ mapping, optional, text, _ }
import play.api.libs.json.{ Json, OFormat }
case class ProfileForm(
vegetarian: Boolean,
seaFoodRestriction: Boolean,
porkRestriction: Boolean,
beefRestriction: Boolean,
chickenRestriction: Boolean,
glutenRestriction: Boolean,
lactoseRestriction: Boolean,
otherRestriction: Option[String]
)
object ProfileForm {
implicit val profileFormFormat: OFormat[DishForm] = Json.format[DishForm]
val profileForm = Form(
mapping(
"vegetarian" -> boolean,
"seaFoodRestriction" -> boolean,
"porkRestriction" -> boolean,
"beefRestriction" -> boolean,
"chickenRestriction" -> boolean,
"glutenRestriction" -> boolean,
"lactoseRestriction" -> boolean,
"otherRestriction" -> optional(text)
)(ProfileForm.apply)(ProfileForm.unapply)
)
}
开发者ID:lunatech-labs,项目名称:lunatech-lunch-planner,代码行数:34,代码来源:ProfileForm.scala
示例4: DishForm
//设置package包名称以及导入依赖的类
package lunatech.lunchplanner.viewModels
import java.util.UUID
import play.api.data.Form
import play.api.data.Forms.{ mapping, optional, text, _ }
import play.api.data.format.Formats._
import play.api.libs.json.{ Json, OFormat }
case class DishForm (
name: String,
description: String,
isVegetarian: Boolean = false,
hasSeaFood: Boolean = false,
hasPork: Boolean = false,
hasBeef: Boolean = false,
hasChicken: Boolean = false,
isGlutenFree: Boolean = false,
hasLactose: Boolean = false,
remarks: Option[String] = None
)
object DishForm {
implicit val dishFormFormat: OFormat[DishForm] = Json.format[DishForm]
val dishForm = Form(
mapping(
"name" -> nonEmptyText,
"description" -> nonEmptyText,
"isVegetarian" -> boolean,
"hasSeaFood" -> boolean,
"hasPork" -> boolean,
"hasBeef" -> boolean,
"hasChicken" -> boolean,
"isGlutenFree" -> boolean,
"hasLactose" -> boolean,
"remarks" -> optional(text)
)(DishForm.apply)(DishForm.unapply)
)
}
case class ListDishesForm(listUuids: List[UUID])
object ListDishesForm {
val listDishesForm = Form(
mapping(
"uuid" -> list(of[UUID])
)(ListDishesForm.apply)(ListDishesForm.unapply)
)
}
开发者ID:lunatech-labs,项目名称:lunatech-lunch-planner,代码行数:51,代码来源:DishForm.scala
示例5: NewLinkForm
//设置package包名称以及导入依赖的类
package models.forms
import models.LinkAddData
import play.api.data.Form
import play.api.data.Forms.{mapping, nonEmptyText, optional, text, longNumber}
import play.api.data.validation.{Constraint, Invalid, Valid}
object NewLinkForm {
private val urlRegex = "(^|[\\s.:;?\\-\\]<\\(])(https?://[-\\w;/?:@&=+$\\|\\_.!~*\\|'()\\[\\]%#,?]+[\\w/#](\\(\\))?)(?=$|[\\s',\\|\\(\\).:;?\\-\\[\\]>\\)])"
private val urlContraint = Constraint[String] { s: String =>
if (s.matches(urlRegex))
Valid
else
Invalid("is not a valid url")
}
val form = Form(
mapping(
"url" -> nonEmptyText.verifying(urlContraint),
"name" -> optional(text),
"description" -> optional(text),
"parentId" -> optional(longNumber)
)(LinkAddData.apply)(LinkAddData.unapply)
)
}
开发者ID:agoetschm,项目名称:linkmanager,代码行数:28,代码来源:NewLinkForm.scala
示例6: Application
//设置package包名称以及导入依赖的类
package controllers
import dao.CatDAO
import dao.DogDAO
import javax.inject.Inject
import models.Cat
import play.api.data.Form
import play.api.data.Forms.mapping
import play.api.data.Forms.text
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.api.mvc.Action
import play.api.mvc.Controller
import models.Dog
class Application @Inject() (catDao: CatDAO, dogDao: DogDAO) extends Controller {
def index = Action.async {
catDao.all().zip(dogDao.all()).map {case (cats, dogs) => Ok(views.html.index(cats, dogs)) }
}
def react = Action {
Ok(views.html.react())
}
val catForm = Form(
mapping(
"name" -> text(),
"color" -> text()
)(Cat.apply)(Cat.unapply)
)
val dogForm = Form(
mapping(
"name" -> text(),
"color" -> text()
)(Dog.apply)(Dog.unapply)
)
def insertCat = Action.async { implicit request =>
val cat: Cat = catForm.bindFromRequest.get
catDao.insert(cat).map(_ => Redirect(routes.Application.index))
}
def insertDog = Action.async { implicit request =>
val dog: Dog = dogForm.bindFromRequest.get
dogDao.insert(dog).map(_ => Redirect(routes.Application.index))
}
}
开发者ID:namelos,项目名称:play-slick-boilerplate,代码行数:49,代码来源:Application.scala
示例7: Application
//设置package包名称以及导入依赖的类
package controllers
import dao.TaskDao
import javax.inject.Inject
import play.api.data.Form
import play.api.data.Forms.mapping
import play.api.data.Forms.number
import play.api.data.Forms.text
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.api.mvc.Action
import play.api.mvc.Controller
class Application @Inject() (taskDao: TaskDao) extends Controller {
var accessNum: Integer = 0
def index = Action {
Redirect(routes.TaskController.task)
}
def randam = Action { implicit request =>
accessNum += 1
Ok(views.html.randam("??" + accessNum))
}
}
开发者ID:tyutyu08,项目名称:testScalaPlay,代码行数:28,代码来源:Application.scala
示例8: RegistrationForm
//设置package包名称以及导入依赖的类
package forms
import play.api.data.Form
import play.api.data.Forms.{text, tuple}
import play.api.data.validation.Constraints
//TODO: Add verification checks for existing username/email and password strength
object RegistrationForm {
val registrationForm = Form(
tuple(
"First Name" -> text.verifying("registration.firstname.required", _.nonEmpty)
.verifying("registration.firstname.capital.required", x => x.matches("^[A-Z].*")),
"Last Name" -> text.verifying("registration.lastname.required", _.nonEmpty)
.verifying("registration.lastname.capital.required", x => x.matches("^[A-Z].*")),
"Email" -> text.verifying("registration.email.required", _.nonEmpty)
.verifying("registration.email.format", x => x.matches(emailRegex)),
"Username" -> text,
"Password" -> text
)
)
}
//TODO: Add verification checks to see if username exists and whether password matches
object LoginForm {
val loginForm = Form(
tuple(
"Username" -> text.verifying("login.username.required", _.nonEmpty),
"Password" -> text.verifying("login.password.required", _.nonEmpty)
)
)
}
开发者ID:nkaraolis,项目名称:Star-Wars-Stock-Market,代码行数:33,代码来源:RegistrationForm.scala
注:本文中的play.api.data.Forms.text类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论