Mercurial > hg > Members > nobuyasu > tasks
view app/controllers/Application.java @ 7:84e51aafdfed draft
Building the first screen
author | e085711 |
---|---|
date | Thu, 13 Sep 2012 10:37:20 +0900 (2012-09-13) |
parents | b216e48fc4a5 |
children | 87c015a99196 |
line wrap: on
line source
package controllers; import play.*; import play.mvc.*; import java.util.*; import models.*; public class Application extends Controller { @Before static void addDefaults() { renderArgs.put("blogTitle",Play.configuration.getProperty("blog.title")); renderArgs.put("blogBaseline",Play.configuration.getProperty("blog.baseline")); } public static void index() { Post frontPost = Post.find("order by postedAt desc").first(); List<Post> olderPosts = Post.find("order by postedAt desc").from(1).fetch(10); render(frontPost,olderPosts); } public static void createTask(String title) { Task task = new Task(title).save(); renderJSON(task); } public static void changeStatus(Long id, boolean done) { Task task = Task.findById(id); task.done = done; task.save(); renderJSON(task); } public static void dimolto() { ArrayList list = new ArrayList(); list.add("message 1"); list.add("message 2"); list.add("message 3"); render(list); } public static void show(Long id) { Post post = Post.findById(id); render(post); } }