Skip to content

Instantly share code, notes, and snippets.

@kunst1080 kunst1080/Application.java
Last active May 27, 2016

Embed
What would you like to do?
Play2.5 Java Controller Sample
private FormFactory formFactory;
private Form<SearchForm> form() {
return formFactory.form(SearchForm.class);
}
public Result index() {
val form = new SearchForm();
return ok(views.html.index.render(form().fill(form)));
}
public Result submit() {
val resultForm = form().bindFromRequest();
if (resultForm.hasErrors()) {
return badRequest(views.html.index.render(resultForm));
}
val form = resultForm.get();
return ok(views.html.index.render(form().fill(form)));
}
package forms;
import lombok.Data;
import lombok.ToString;
@Data
@ToString
public class SearchForm {
private String ssearchText;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.