|
Play Framework/Scala example source code file (Resource1.scala)
The Resource1.scala Play Framework example source code/* * Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com> */ package controllers import play.api._ import play.api.mvc._ import play.api.data._ import play.api.data.Forms._ object Resource1 extends Controller { val form = Form( tuple( "foo" -> text, "bar" -> text ) ) def index = Action { Ok(views.html.resource1.index(Seq(1, 2, 3))) } def get(id: Long) = Action { Ok(views.html.resource1.item(id, ("foo", "bar"))) } def create = Action { Ok(views.html.resource1.edit(None, form)) } def save = Action { implicit req => form.bindFromRequest().fold( error => Ok(views.html.resource1.edit(None, error)), data => Redirect(routes.Resource1.get(100)) ) } def edit(id: Long) = Action { Ok(views.html.resource1.edit(Some(id), form)) } def update(id: Long) = Action { implicit req => form.bindFromRequest().fold( error => Ok(views.html.resource1.edit(Some(id), error)), data => Redirect(routes.Resource1.get(id)) ) } def delete(id: Long) = Action { Redirect(routes.Resource1.index()) } def foo(id: Long) = Action { Ok("Foo: " + id) } } Other Play Framework source code examplesHere is a short list of links related to this Play Framework Resource1.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.