Skip to content

Commit

Permalink
ported test-application to Play 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
corux committed May 25, 2013
1 parent 14d9576 commit 55b58a6
Show file tree
Hide file tree
Showing 18 changed files with 847 additions and 1,120 deletions.
15 changes: 15 additions & 0 deletions test-application/.gitignore
@@ -0,0 +1,15 @@
logs
project/project
project/target
target
tmp
.history
dist
/.idea
/*.iml
/out
/.idea_modules
/.classpath
/.project
/RUNNING_PID
/.settings
38 changes: 30 additions & 8 deletions test-application/app/controllers/LocalizedApplication.java
@@ -1,31 +1,53 @@
package controllers;

import org.apache.commons.lang.StringUtils;
import static play.data.Form.form;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

import play.data.DynamicForm;
import play.i18n.Lang;
import play.i18n.Messages;
import play.mvc.Controller;
import play.mvc.Result;

/**
* @author huljas
*/
public class LocalizedApplication extends Controller {

public static void hello(String name) {
public static List<String> getLangs() {
List<String> list = new ArrayList<>();
for (Lang i : Lang.availables()) {
list.add(i.code());
}

return list;
}

public static Result hello() {
DynamicForm f = form().bindFromRequest();
String name = f.get("name");
if (StringUtils.isBlank(name)) {
name = Messages.get("you");
}
String hello = Messages.get("hello.type.normal", name);
render(hello);
return ok(views.html.hello.render(hello));
}

public static void helloWithType(String name, String type) {
public static Result helloWithType() {
DynamicForm f = form().bindFromRequest();
String name = f.get("name");
String type = f.get("type");
String hello = Messages.get("hello.type." + type, name);
render("@hello", hello);
return ok(views.html.hello.render(hello));
}

public static void setLang(String lang) {
Lang.change(lang);
hello(null);
public static Result setLang(String lang) {
changeLang(lang);
return hello();
}

}
33 changes: 0 additions & 33 deletions test-application/app/views/LocalizedApplication/hello.html

This file was deleted.

0 comments on commit 55b58a6

Please sign in to comment.