Skip to content

Commit

Permalink
Added Play Files
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan committed Mar 5, 2018
1 parent 1f3c0d1 commit c9e9f0f
Show file tree
Hide file tree
Showing 435 changed files with 176,286 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .g8/form/app/controllers/$model__Camel$Controller.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package controllers;

import play.data.Form;
import play.data.FormFactory;
import play.mvc.Controller;
import play.mvc.Result;

import javax.inject.Inject;

// Add the following to conf/routes
/*
GET /$model;format="camel"$ controllers.$model;format="Camel"$Controller.$model;format="camel"$Get
POST /$model;format="camel"$ controllers.$model;format="Camel"$Controller.$model;format="camel"$Post
*/

/**
* $model;format="Camel"$ form controller for Play Java
*/
public class $model;format="Camel"$Controller extends Controller {

private final Form<$model;format="Camel"$Data> $model;format="camel"$Form;

@Inject
public $model;format="Camel"$Controller(FormFactory formFactory) {
this.$model;format="camel"$Form = formFactory.form($model;format="Camel"$Data.class);
}

public Result $model;format="camel"$Get() {
return ok(views.html.$model;format="camel"$.form.render($model;format="camel"$Form));
}

public Result $model;format="camel"$Post() {
Form<$model;format="Camel"$Data> boundForm = $model;format="camel"$Form.bindFromRequest();
if (boundForm.hasErrors()) {
return badRequest(views.html.$model;format="camel"$.form.render(boundForm));
} else {
$model;format="Camel"$Data $model;format="camel"$ = boundForm.get();
flash("success", "$model;format="Camel"$ " + $model;format="camel"$);
return redirect(routes.$model;format="Camel"$Controller.$model;format="camel"$Get());
}
}

}
37 changes: 37 additions & 0 deletions .g8/form/app/controllers/$model__Camel$Data.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package controllers;

import play.data.validation.Constraints;

public class $model;format="Camel"$Data {

@Constraints.Required
private String name;

@Constraints.Required
private Integer age;

public $model;format="Camel"$Data() {
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Integer getAge() {
return age;
}

public void setAge(Integer age) {
this.age = age;
}

@Override
public String toString() {
return String.format("$model;format="Camel"$Data(%s, %s)", name, age);
}

}
12 changes: 12 additions & 0 deletions .g8/form/app/views/$model__camel$/form.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@($model;format="camel"$Form: Form[$model;format="Camel"$Data])

<h1>$model;format="camel"$ form</h1>

@flash.getOrDefault("success", "")

@helper.form(action = routes.$model;format="Camel"$Controller.$model;format="camel"$Post()) {
@helper.CSRF.formField
@helper.inputText($model;format="camel"$Form("name"))
@helper.inputText($model;format="camel"$Form("age"))
<input type="submit" value="submit"/>
}
2 changes: 2 additions & 0 deletions .g8/form/default.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
description = Generates a Controller with form handling
model = user
1 change: 1 addition & 0 deletions .g8/form/generated-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Temporary file until g8-scaffold will generate "test" directory
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package controllers;

import org.junit.Test;
import play.Application;
import play.filters.csrf.*;
import play.inject.guice.GuiceApplicationBuilder;
import play.mvc.*;
import play.test.WithApplication;

import java.util.HashMap;

import static org.junit.Assert.assertEquals;
import static play.mvc.Http.RequestBuilder;
import static play.mvc.Http.Status.OK;
import static play.test.Helpers.*;
import static play.api.test.CSRFTokenHelper.*;

public class $model;format="Camel"$ControllerTest extends WithApplication {

@Override
protected Application provideApplication() {
return new GuiceApplicationBuilder().build();
}

@Test
public void test$model;format="Camel"$Get() {
RequestBuilder request = new RequestBuilder()
.method(GET)
.uri("/$model;format="camel"$");

Result result = route(app, request);
assertEquals(OK, result.status());
}

@Test
public void test$model;format="Camel"$Post() {
HashMap<String, String> formData = new HashMap<>();
formData.put("name", "play");
formData.put("age", "4");
RequestBuilder request = addCSRFToken(new RequestBuilder()
.header(Http.HeaderNames.HOST, "localhost")
.method(POST)
.bodyForm(formData)
.uri("/$model;format="camel"$"));

Result result = route(app, request);
assertEquals(SEE_OTHER, result.status());
}

}
Binary file added .gradle/4.4/fileChanges/last-build.bin
Binary file not shown.
Binary file added .gradle/4.4/fileHashes/fileHashes.bin
Binary file not shown.
Binary file added .gradle/4.4/fileHashes/fileHashes.lock
Binary file not shown.
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>lab3</name>
<comment>Project lab3 created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
2 changes: 2 additions & 0 deletions .settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Mon Mar 05 11:40:24 GMT 2018
connection.project.dir=
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "disabled"
}
Loading

0 comments on commit c9e9f0f

Please sign in to comment.