-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jordan
committed
Mar 5, 2018
1 parent
1f3c0d1
commit c9e9f0f
Showing
435 changed files
with
176,286 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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()); | ||
} | ||
} | ||
|
||
} |
This file contains 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
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); | ||
} | ||
|
||
} |
This file contains 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
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"/> | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
description = Generates a Controller with form handling | ||
model = user |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Temporary file until g8-scaffold will generate "test" directory |
50 changes: 50 additions & 0 deletions
50
.g8/form/generated-test/controllers/$model__Camel$ControllerTest.java
This file contains 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
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 not shown.
Binary file not shown.
Binary file not shown.
This file contains 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
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> |
This file contains 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
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= |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"java.configuration.updateBuildConfiguration": "disabled" | ||
} |
Oops, something went wrong.