A quick talk that was given during 2010 about the main features of Play! framework.
This was given to the development team at Evoolv, which has kickstarted the web development over Play! framework which turned out was a decent choice.
4. Routing : /conf/routes
● Examples
GET /profile/view/{id} ProfileController.view
POST /profile/save ProfileController.save
GET /{<ar|en>lang}/ HomeController.index
* /{controller}/{action} {controller}.{action}
● Defining the URLs early, forces you to explore your website
● You can use annotations too (with the play-router module)
5. Controllers : /app/controllers
import play.mvc.Controller;
public class ProfileController extends Controller {
public static void view(Long id) {
// ...
renderText("123"); // or json, xml.
renderTemplate("Users/show.html");
redirect("....");
HomeController.index(); // Does a redirect
// ...
}
}
6. Models : /app/models
import play.db.jpa.Model;
import javax.persistence.Entity;
@Entity
public class User extends Model {
public String email;
public String password;
}
7. Validations : /app/models
import play.db.jpa.Model;
import javax.persistence.Entity;
import play.data.validation.*;
@Entity
public class User extends Model {
@Email @Required
public String email;
@Required @MinSize(5)
public String password;
}
8. Validations : /app/controllers
import play.mvc.Controller;
public class ProfileController extends Controller {
public static void view(@Valid Profile profile) {
render(profile);
// or invoke the validation manually !
// validation.valid(profile)
}
}