Skip to content

Instantly share code, notes, and snippets.

@kunst1080
Last active May 27, 2016 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kunst1080/b993e5724f6efcb718975f055ee64139 to your computer and use it in GitHub Desktop.
Save kunst1080/b993e5724f6efcb718975f055ee64139 to your computer and use it in GitHub Desktop.
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