SlideShare uma empresa Scribd logo
1 de 17
Baixar para ler offline
Dive into           Framework

            Maher Gamal
Key Features

● Agile development workflow ( Save, Reload ! )

● Stateless architecture

● Clear error reporting

● Reusable modules & plugins

● Gets you up and running quickly !
Project Layout : play new proj1

● proj1/app/controllers
● proj1/app/models
● proj1/app/views

● proj1/conf/application.conf
● proj1/conf/messages
● proj1/conf/routes

● proj1/lib
● proj1/public
● proj1/test
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)
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
      // ...
    }
}
Models : /app/models

import play.db.jpa.Model;
import javax.persistence.Entity;


@Entity
public class User extends Model {

    public String email;

    public String password;
}
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;
}
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)
    }
}
Views : /app/views

/app/views/ProfileController/view.html

#{ifErrors}

  <ul class="error">
    #{errors}
       <li>${error}</li>
    #{/errors}
  </ul>

#{/ifErrors}
Views : /app/views

/app/views/ProfileController/view.html
#{extends 'main.html' /}
#{set title : 'Page Title' /}
#{set 'moreScripts'}
  ...
#{/set}

/app/views/main.html
<html>
   <head>
     <title>#{get 'title' /}</title>
     #{get 'moreScripts' /}
   </head>
</html>
Views : /app/views

/app/views/main.html
<html>
   <head>
     <title>#{get 'title' /}</title>
     #{get 'moreScripts' /}
   </head>
   <body>
     ...
     #{doLayout /}
     ...
   </body>
</html>
Jobs : /app/jobs


public class BootstrapJob extends Job {

    @Override
    public void doJob() {
      ...
    }
}
Jobs : /app/jobs

@OnApplicationStart
public class BootstrapJob extends Job {

    @Override
    public void doJob() {
      ...
    }
}
Jobs : /app/jobs

@Every("1h") or @On("0 0 * * *")
public class BootstrapJob extends Job {

    @Override
    public void doJob() {
      ...
    }
}
Helper Libraries : play.libs.*

 ● MD5 , SHA1 , Base64 Encoding/Decoding
 ● Encryption , decryption , hashing
 ● File/Directory copying , deleting and I/O methods
 ● Image resizing , cropping and captcha generation
 ● Mail message preparation and sending
 ● OAuth Integration
 ● OpenID Integration
 ● HttpClient to call external web services
 ● XML Parsing
Running

● play new proj1

● play run proj1

● play clean,run proj1

● play netbeansify proj1

● play help
Resources

● Documentation
   ○ playframework.org/documentation
   ○ playframework.org/documentation/api/1.1.1/index.html

● Community
   ○ playframework.org/community
   ○ play.lighthouseapp.com
   ○ groups.google.com/group/play-framework

● Modules and Examples
   ○ playframework.org/modules
   ○ Check samples-and-tests directory in the release

Mais conteúdo relacionado

Mais procurados

Simple restfull app_s
Simple restfull app_sSimple restfull app_s
Simple restfull app_s
netwix
 
Behavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberBehavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using Cucumber
KMS Technology
 
[Fronthub 2016] Константин Макарычев: "Не быстрый старт с Angular 2"
[Fronthub 2016] Константин Макарычев: "Не быстрый старт с Angular 2"[Fronthub 2016] Константин Макарычев: "Не быстрый старт с Angular 2"
[Fronthub 2016] Константин Макарычев: "Не быстрый старт с Angular 2"
Provectus
 

Mais procurados (20)

13.exemplu closure controller
13.exemplu closure controller13.exemplu closure controller
13.exemplu closure controller
 
Simple restfull app_s
Simple restfull app_sSimple restfull app_s
Simple restfull app_s
 
Java EE 6
Java EE 6Java EE 6
Java EE 6
 
OpenCms Days 2015 Hidden features of OpenCms
OpenCms Days 2015 Hidden features of OpenCmsOpenCms Days 2015 Hidden features of OpenCms
OpenCms Days 2015 Hidden features of OpenCms
 
Automated Smoke Tests with Protractor
Automated Smoke Tests with ProtractorAutomated Smoke Tests with Protractor
Automated Smoke Tests with Protractor
 
Gatling Performance Workshop
Gatling Performance WorkshopGatling Performance Workshop
Gatling Performance Workshop
 
Codeception: introduction to php testing
Codeception: introduction to php testingCodeception: introduction to php testing
Codeception: introduction to php testing
 
Test automation with php codeception
Test automation with php codeceptionTest automation with php codeception
Test automation with php codeception
 
ASP.NET Routing & MVC
ASP.NET Routing & MVCASP.NET Routing & MVC
ASP.NET Routing & MVC
 
Behavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberBehavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using Cucumber
 
UI Testing Best Practices - An Expected Journey
UI Testing Best Practices - An Expected JourneyUI Testing Best Practices - An Expected Journey
UI Testing Best Practices - An Expected Journey
 
[Fronthub 2016] Константин Макарычев: "Не быстрый старт с Angular 2"
[Fronthub 2016] Константин Макарычев: "Не быстрый старт с Angular 2"[Fronthub 2016] Константин Макарычев: "Не быстрый старт с Angular 2"
[Fronthub 2016] Константин Макарычев: "Не быстрый старт с Angular 2"
 
Catching bugs with Opera Dragonfly / Özgür Web Teknolojileri Günleri / Istanb...
Catching bugs with Opera Dragonfly / Özgür Web Teknolojileri Günleri / Istanb...Catching bugs with Opera Dragonfly / Özgür Web Teknolojileri Günleri / Istanb...
Catching bugs with Opera Dragonfly / Özgür Web Teknolojileri Günleri / Istanb...
 
Codeception introduction and use in Yii
Codeception introduction and use in YiiCodeception introduction and use in Yii
Codeception introduction and use in Yii
 
Oro Workflows
Oro WorkflowsOro Workflows
Oro Workflows
 
Breaking free from static abuse in test automation frameworks and using Sprin...
Breaking free from static abuse in test automation frameworks and using Sprin...Breaking free from static abuse in test automation frameworks and using Sprin...
Breaking free from static abuse in test automation frameworks and using Sprin...
 
How to use_cucumber_rest-assured_api_framework
How to use_cucumber_rest-assured_api_frameworkHow to use_cucumber_rest-assured_api_framework
How to use_cucumber_rest-assured_api_framework
 
[EclipseCon NA 2014] Integration tests for RCP made easy with SWTBot and Tycho
[EclipseCon NA 2014] Integration tests for RCP made easy with SWTBot and Tycho[EclipseCon NA 2014] Integration tests for RCP made easy with SWTBot and Tycho
[EclipseCon NA 2014] Integration tests for RCP made easy with SWTBot and Tycho
 
Laravel & Composer presentation - extended
Laravel & Composer presentation - extendedLaravel & Composer presentation - extended
Laravel & Composer presentation - extended
 
Testing Web Applications
Testing Web ApplicationsTesting Web Applications
Testing Web Applications
 

Destaque

Brain Fitness2.Pdf Mck Coverage 2009
Brain Fitness2.Pdf Mck Coverage 2009Brain Fitness2.Pdf Mck Coverage 2009
Brain Fitness2.Pdf Mck Coverage 2009
Dakim BrainFitness
 
Committing to Quality in Education: Arts at the Core
Committing to Quality in Education: Arts at the CoreCommitting to Quality in Education: Arts at the Core
Committing to Quality in Education: Arts at the Core
Arts Alliance Illinois
 

Destaque (17)

2013 bridal menus
2013 bridal menus2013 bridal menus
2013 bridal menus
 
Nuevo rumbo
Nuevo rumboNuevo rumbo
Nuevo rumbo
 
Roll Call On Responsible Budget
Roll Call On Responsible BudgetRoll Call On Responsible Budget
Roll Call On Responsible Budget
 
Nuevo rumbo
Nuevo rumboNuevo rumbo
Nuevo rumbo
 
Who says what to whom on Twitter? - Twitter flow
Who says what to whom on Twitter? - Twitter flowWho says what to whom on Twitter? - Twitter flow
Who says what to whom on Twitter? - Twitter flow
 
Brain Fitness2.Pdf Mck Coverage 2009
Brain Fitness2.Pdf Mck Coverage 2009Brain Fitness2.Pdf Mck Coverage 2009
Brain Fitness2.Pdf Mck Coverage 2009
 
A Sip of Python
A Sip of PythonA Sip of Python
A Sip of Python
 
Pastor Austine's ppt
Pastor Austine's pptPastor Austine's ppt
Pastor Austine's ppt
 
First Census of Marine Life 2010
First Census of Marine Life 2010First Census of Marine Life 2010
First Census of Marine Life 2010
 
Arts Activism 101
Arts Activism 101Arts Activism 101
Arts Activism 101
 
Gujrat
GujratGujrat
Gujrat
 
Understanding General Ledger Reconciliations
Understanding General Ledger ReconciliationsUnderstanding General Ledger Reconciliations
Understanding General Ledger Reconciliations
 
Cu hedgehog concept public
Cu hedgehog concept   publicCu hedgehog concept   public
Cu hedgehog concept public
 
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
 
Committing to Quality in Education: Arts at the Core
Committing to Quality in Education: Arts at the CoreCommitting to Quality in Education: Arts at the Core
Committing to Quality in Education: Arts at the Core
 
A Security Analysis Framework Powered By An Expert System
A Security Analysis Framework Powered By An Expert SystemA Security Analysis Framework Powered By An Expert System
A Security Analysis Framework Powered By An Expert System
 
Functors, Applicatives and Monads In Scala
Functors, Applicatives and Monads In ScalaFunctors, Applicatives and Monads In Scala
Functors, Applicatives and Monads In Scala
 

Semelhante a Dive into Play Framework

TangoWithDjango - ch8
TangoWithDjango - ch8TangoWithDjango - ch8
TangoWithDjango - ch8
Asika Kuo
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
 
eXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework IntroductioneXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework Introduction
vstorm83
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran Mizrahi
Ran Mizrahi
 
Module, AMD, RequireJS
Module, AMD, RequireJSModule, AMD, RequireJS
Module, AMD, RequireJS
偉格 高
 

Semelhante a Dive into Play Framework (20)

Web Applications with AngularJS
Web Applications with AngularJSWeb Applications with AngularJS
Web Applications with AngularJS
 
Good practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsGood practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium tests
 
Play framework
Play frameworkPlay framework
Play framework
 
TangoWithDjango - ch8
TangoWithDjango - ch8TangoWithDjango - ch8
TangoWithDjango - ch8
 
Création d'application Ionic & Angular & Drupal 8
Création d'application Ionic & Angular & Drupal 8Création d'application Ionic & Angular & Drupal 8
Création d'application Ionic & Angular & Drupal 8
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Gwt.create
Gwt.createGwt.create
Gwt.create
 
DrupalCon Dublin 2016 - Automated browser testing with Nightwatch.js
DrupalCon Dublin 2016 - Automated browser testing with Nightwatch.jsDrupalCon Dublin 2016 - Automated browser testing with Nightwatch.js
DrupalCon Dublin 2016 - Automated browser testing with Nightwatch.js
 
eXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework IntroductioneXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework Introduction
 
Test your modules
Test your modulesTest your modules
Test your modules
 
Android UI Testing with Appium
Android UI Testing with AppiumAndroid UI Testing with Appium
Android UI Testing with Appium
 
بررسی چارچوب جنگو
بررسی چارچوب جنگوبررسی چارچوب جنگو
بررسی چارچوب جنگو
 
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud RunDesigning flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
 
Google app-engine-with-python
Google app-engine-with-pythonGoogle app-engine-with-python
Google app-engine-with-python
 
Built to last javascript for enterprise
Built to last   javascript for enterpriseBuilt to last   javascript for enterprise
Built to last javascript for enterprise
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
 
Voorhoede - Front-end architecture
Voorhoede - Front-end architectureVoorhoede - Front-end architecture
Voorhoede - Front-end architecture
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran Mizrahi
 
Module, AMD, RequireJS
Module, AMD, RequireJSModule, AMD, RequireJS
Module, AMD, RequireJS
 
PhoneGap
PhoneGapPhoneGap
PhoneGap
 

Último

Último (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

Dive into Play Framework

  • 1. Dive into Framework Maher Gamal
  • 2. Key Features ● Agile development workflow ( Save, Reload ! ) ● Stateless architecture ● Clear error reporting ● Reusable modules & plugins ● Gets you up and running quickly !
  • 3. Project Layout : play new proj1 ● proj1/app/controllers ● proj1/app/models ● proj1/app/views ● proj1/conf/application.conf ● proj1/conf/messages ● proj1/conf/routes ● proj1/lib ● proj1/public ● proj1/test
  • 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) } }
  • 9. Views : /app/views /app/views/ProfileController/view.html #{ifErrors} <ul class="error"> #{errors} <li>${error}</li> #{/errors} </ul> #{/ifErrors}
  • 10. Views : /app/views /app/views/ProfileController/view.html #{extends 'main.html' /} #{set title : 'Page Title' /} #{set 'moreScripts'} ... #{/set} /app/views/main.html <html> <head> <title>#{get 'title' /}</title> #{get 'moreScripts' /} </head> </html>
  • 11. Views : /app/views /app/views/main.html <html> <head> <title>#{get 'title' /}</title> #{get 'moreScripts' /} </head> <body> ... #{doLayout /} ... </body> </html>
  • 12. Jobs : /app/jobs public class BootstrapJob extends Job { @Override public void doJob() { ... } }
  • 13. Jobs : /app/jobs @OnApplicationStart public class BootstrapJob extends Job { @Override public void doJob() { ... } }
  • 14. Jobs : /app/jobs @Every("1h") or @On("0 0 * * *") public class BootstrapJob extends Job { @Override public void doJob() { ... } }
  • 15. Helper Libraries : play.libs.* ● MD5 , SHA1 , Base64 Encoding/Decoding ● Encryption , decryption , hashing ● File/Directory copying , deleting and I/O methods ● Image resizing , cropping and captcha generation ● Mail message preparation and sending ● OAuth Integration ● OpenID Integration ● HttpClient to call external web services ● XML Parsing
  • 16. Running ● play new proj1 ● play run proj1 ● play clean,run proj1 ● play netbeansify proj1 ● play help
  • 17. Resources ● Documentation ○ playframework.org/documentation ○ playframework.org/documentation/api/1.1.1/index.html ● Community ○ playframework.org/community ○ play.lighthouseapp.com ○ groups.google.com/group/play-framework ● Modules and Examples ○ playframework.org/modules ○ Check samples-and-tests directory in the release