Created
June 13, 2013 19:19
-
-
Save jannylund/5776542 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$ cat conf/routes | |
# Routes | |
# This file defines all application routes (Higher priority routes first) | |
# ~~~~ | |
# Home page | |
GET / controllers.Application.index() | |
GET /noflash controllers.Application.indexNoFlash() | |
# Map static resources from the /public folder to the /assets URL path | |
GET /assets/*file controllers.Assets.at(path="/public", file) | |
$ cat app/controllers/Application.java | |
package controllers; | |
import play.mvc.Controller; | |
import play.mvc.Result; | |
import views.html.index; | |
public class Application extends Controller { | |
public static Result index() { | |
flash("success", "foo"); | |
return ok(index.render("Your new application is ready.")); | |
} | |
public static Result indexNoFlash() { | |
return ok(index.render("Your new application is ready.")); | |
} | |
} | |
$ cat app/views/index.scala.html | |
@(message: String) | |
@main("Welcome to Play 2.1") { | |
<div> | |
@if(flash.containsKey("success")) { | |
<strong>flash success: </strong> @flash.get("success") | |
} else { | |
<strong>no flash at all</strong> | |
} | |
</div> | |
<div> | |
<a href='@routes.Application.index()'>Show page with flash.</a> | |
<a href='@routes.Application.indexNoFlash()'>Show page with no flash.</a> | |
</div> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment