Last active
May 27, 2016 07:44
-
-
Save kunst1080/b993e5724f6efcb718975f055ee64139 to your computer and use it in GitHub Desktop.
Play2.5 Java Controller Sample
This file contains hidden or 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
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))); | |
} |
This file contains hidden or 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
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