SlideShare uma empresa Scribd logo
1 de 15
developing web applications using Java and the Play framework
What is Play? A clean alternative to the bloated Java Enterprise Edition Pure Java framework – allows you to keep your preferred development tools and libraries Focuses on developer productivity and targets RESTful(Representational State Transfer) architectures Consist of clients and servers Clients initiate requests to servers Servers process requests and return appropriate responses Requests and responses are built around the transfer of representations of resources
The foundation of Play MVC architecture You’ve got a database on one side and a web browser on the other. Classes are models, the application is the controller, generated HTML is the view HTTP-to-code mapping Example: binding URI patterns to Java procedure calls Efficient template engine The expression language used is Groovy Templating system mainly used to render HTML responses
Why is play awesome? Fix the bug and hit reload The framework compiles your Java sources directly and hot-reloads them into the JVM without the need to restart the server You can then edit, reload and see your modifications immediately, just as in a Rails environment Whenever an error occurs, the framework identifies and shows you the problem Stack traces are stripped down and optimized to make it easier to solve problems Java Persistence API (JPA) and The Java Persistence Query Language (JPQL)  A persistence entity is a lightweight Java class saved to a table in a relational database.
JPA, JPQL // Java Persistence API example @Entity  public class Book {  @Id  private Integer id;  private String title;  private String isbn;  	@ManyToOne 	private Publisher publisher;  	@ManyToMany private List<Author> authors;  }
JPA, JPQL // Java Persistence Query Language example public void messages(intpage, User connectedUser) { List<Message> messages = Message.find(“ 	user = ?  	and read = false  	order by date desc",  connectedUser).from(page * 10).fetch(10);  render(connectedUser, messages);  }
Why is play awesome? Test-driven development Run them directly in a browser using Selenium Selenium is a Firefox add-on that records clicks, typing, and other actions Database support through JDBC Object-relational mapping using Hibernate (with the JPA API) Integrated cache support Straightforward web services consumption either in JSON or XML OpenIDsupport for distributed authentication Ready to be deployed anywhere (application server, Google App Engine, Cloud, etc…) Image manipulation API.
Things you can do with play
Things you can do with play Bind an HTTP parameter to a Java method parameter // a simple request /articles/archive?date=08/01/08&page=2 // the Java method public staticvoid archive(Date date, Integer page) {  List<Article> articles = Articles.fromArchive(date, page); render(articles);  }
Things you can do with play Smart binding with any class // a simple model public class Person {  public String name;  public Integer age;  } // a simple controller public static void add(Person p) { 	p.save(); } // a simple HTML form <form action="add" method="POST"> 	Name: <input type="text" name="p.name" />  	Age: <input type="text" name="p.age" />  </form>
Things you can do with play Redirect to an action by calling the corresponding Java method // a simple model with a procedure public static void show(Long id) {  Article article = Article.findById(id);  render(article);  } // use the equivalent syntax: <a href="@{Article.show(article.id)}"> ${article.title} </a>
Things you can do with play Redirect to an action by calling the corresponding Java method (another example) // a simple model with a procedure public static void edit(Long id, String title) {  Article article = Article.findById(id);  article.title= title;  article.save(); show(id);  } // generated HTML: <a href="/articles/15"> My new article </a>
Things you can do with play Straightforward file upload management // the Java code public static void uploadPhoto(String title, File photo) {  	...  } // a simple HTML form <form action="@{Article.uploadPhoto()}" method="POST" 							enctype="multipart/form-data">  	<input type="text" name="title" />  	<input type="file" id="photo" name="photo" />  	<input type="submit" value="Send it..." /> </form>
DEMO Let’s create our own web application:  a personal agenda
Questions?

Mais conteúdo relacionado

Mais procurados

Java script performance tips
Java script performance tipsJava script performance tips
Java script performance tips
Shakti Shrestha
 

Mais procurados (20)

Angular Seminar-js
Angular Seminar-jsAngular Seminar-js
Angular Seminar-js
 
Angular 2 overview
Angular 2 overviewAngular 2 overview
Angular 2 overview
 
AngularJS
AngularJSAngularJS
AngularJS
 
Kickstart sencha extjs
Kickstart sencha extjsKickstart sencha extjs
Kickstart sencha extjs
 
Angularjs interview questions and answers
Angularjs interview questions and answersAngularjs interview questions and answers
Angularjs interview questions and answers
 
Introduction to AngularJS Framework
Introduction to AngularJS FrameworkIntroduction to AngularJS Framework
Introduction to AngularJS Framework
 
Angular JS Introduction
Angular JS IntroductionAngular JS Introduction
Angular JS Introduction
 
AngularJS interview questions
AngularJS interview questionsAngularJS interview questions
AngularJS interview questions
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Angular Js
Angular JsAngular Js
Angular Js
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJS
 
Angular js
Angular jsAngular js
Angular js
 
Angular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersAngular1x and Angular 2 for Beginners
Angular1x and Angular 2 for Beginners
 
Java script performance tips
Java script performance tipsJava script performance tips
Java script performance tips
 
Angular js interview question answer for fresher
Angular js interview question answer for fresherAngular js interview question answer for fresher
Angular js interview question answer for fresher
 
Angular js for beginners
Angular js for beginnersAngular js for beginners
Angular js for beginners
 
AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project 
 
Angularjs PPT
Angularjs PPTAngularjs PPT
Angularjs PPT
 
AngularJS intro
AngularJS introAngularJS intro
AngularJS intro
 
What's new in Angular 2?
What's new in Angular 2?What's new in Angular 2?
What's new in Angular 2?
 

Semelhante a Developing web apps using Java and the Play framework

Java Technology
Java TechnologyJava Technology
Java Technology
ifnu bima
 
eXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework IntroductioneXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework Introduction
vstorm83
 

Semelhante a Developing web apps using Java and the Play framework (20)

CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2
 
Introduction to JSF
Introduction toJSFIntroduction toJSF
Introduction to JSF
 
Java Technology
Java TechnologyJava Technology
Java Technology
 
What is Advance Java J2EE
What is Advance Java J2EEWhat is Advance Java J2EE
What is Advance Java J2EE
 
I Feel Pretty
I Feel PrettyI Feel Pretty
I Feel Pretty
 
Boston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesBoston Computing Review - Java Server Pages
Boston Computing Review - Java Server Pages
 
Jsp
JspJsp
Jsp
 
Google Web Toolkit
Google Web ToolkitGoogle Web Toolkit
Google Web Toolkit
 
sMash at May NYPHP UG
sMash at May NYPHP UGsMash at May NYPHP UG
sMash at May NYPHP UG
 
Play framework
Play frameworkPlay framework
Play framework
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
 
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web ToolkitJava Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
 
Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course
 
Google App Engine for Java (GAE/J)
Google App Engine for Java (GAE/J) Google App Engine for Java (GAE/J)
Google App Engine for Java (GAE/J)
 
Jsp Comparison
 Jsp Comparison Jsp Comparison
Jsp Comparison
 
JSR 168 Portal - Overview
JSR 168 Portal - OverviewJSR 168 Portal - Overview
JSR 168 Portal - Overview
 
Basic Hibernate Final
Basic Hibernate FinalBasic Hibernate Final
Basic Hibernate Final
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
 
eXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework IntroductioneXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework Introduction
 
JEE5 New Features
JEE5 New FeaturesJEE5 New Features
JEE5 New Features
 

Mais de Victor Porof

Mais de Victor Porof (11)

Firefox WebGL developer tools
Firefox WebGL developer toolsFirefox WebGL developer tools
Firefox WebGL developer tools
 
Firefox developer tools
Firefox developer toolsFirefox developer tools
Firefox developer tools
 
Js in the open
Js in the openJs in the open
Js in the open
 
Processing.js vs. three.js
Processing.js vs. three.jsProcessing.js vs. three.js
Processing.js vs. three.js
 
Javascript, Do you speak it!
Javascript, Do you speak it!Javascript, Do you speak it!
Javascript, Do you speak it!
 
Cityquest - Developing games for the mobile devices
Cityquest - Developing games for the mobile devicesCityquest - Developing games for the mobile devices
Cityquest - Developing games for the mobile devices
 
Web3D - Semantic standards, WebGL, HCI
Web3D - Semantic standards, WebGL, HCIWeb3D - Semantic standards, WebGL, HCI
Web3D - Semantic standards, WebGL, HCI
 
Chameleon game engine
Chameleon game engineChameleon game engine
Chameleon game engine
 
Beginners' guide to Ruby on Rails
Beginners' guide to Ruby on RailsBeginners' guide to Ruby on Rails
Beginners' guide to Ruby on Rails
 
Introduction to the XNA framework
Introduction to the XNA frameworkIntroduction to the XNA framework
Introduction to the XNA framework
 
Introduction to 3D and shaders
Introduction to 3D and shadersIntroduction to 3D and shaders
Introduction to 3D and shaders
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
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
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Developing web apps using Java and the Play framework

  • 1. developing web applications using Java and the Play framework
  • 2. What is Play? A clean alternative to the bloated Java Enterprise Edition Pure Java framework – allows you to keep your preferred development tools and libraries Focuses on developer productivity and targets RESTful(Representational State Transfer) architectures Consist of clients and servers Clients initiate requests to servers Servers process requests and return appropriate responses Requests and responses are built around the transfer of representations of resources
  • 3. The foundation of Play MVC architecture You’ve got a database on one side and a web browser on the other. Classes are models, the application is the controller, generated HTML is the view HTTP-to-code mapping Example: binding URI patterns to Java procedure calls Efficient template engine The expression language used is Groovy Templating system mainly used to render HTML responses
  • 4. Why is play awesome? Fix the bug and hit reload The framework compiles your Java sources directly and hot-reloads them into the JVM without the need to restart the server You can then edit, reload and see your modifications immediately, just as in a Rails environment Whenever an error occurs, the framework identifies and shows you the problem Stack traces are stripped down and optimized to make it easier to solve problems Java Persistence API (JPA) and The Java Persistence Query Language (JPQL)  A persistence entity is a lightweight Java class saved to a table in a relational database.
  • 5. JPA, JPQL // Java Persistence API example @Entity public class Book { @Id private Integer id; private String title; private String isbn; @ManyToOne private Publisher publisher; @ManyToMany private List<Author> authors; }
  • 6. JPA, JPQL // Java Persistence Query Language example public void messages(intpage, User connectedUser) { List<Message> messages = Message.find(“ user = ? and read = false order by date desc", connectedUser).from(page * 10).fetch(10); render(connectedUser, messages); }
  • 7. Why is play awesome? Test-driven development Run them directly in a browser using Selenium Selenium is a Firefox add-on that records clicks, typing, and other actions Database support through JDBC Object-relational mapping using Hibernate (with the JPA API) Integrated cache support Straightforward web services consumption either in JSON or XML OpenIDsupport for distributed authentication Ready to be deployed anywhere (application server, Google App Engine, Cloud, etc…) Image manipulation API.
  • 8. Things you can do with play
  • 9. Things you can do with play Bind an HTTP parameter to a Java method parameter // a simple request /articles/archive?date=08/01/08&page=2 // the Java method public staticvoid archive(Date date, Integer page) { List<Article> articles = Articles.fromArchive(date, page); render(articles); }
  • 10. Things you can do with play Smart binding with any class // a simple model public class Person { public String name; public Integer age; } // a simple controller public static void add(Person p) { p.save(); } // a simple HTML form <form action="add" method="POST"> Name: <input type="text" name="p.name" /> Age: <input type="text" name="p.age" /> </form>
  • 11. Things you can do with play Redirect to an action by calling the corresponding Java method // a simple model with a procedure public static void show(Long id) { Article article = Article.findById(id); render(article); } // use the equivalent syntax: <a href="@{Article.show(article.id)}"> ${article.title} </a>
  • 12. Things you can do with play Redirect to an action by calling the corresponding Java method (another example) // a simple model with a procedure public static void edit(Long id, String title) { Article article = Article.findById(id); article.title= title; article.save(); show(id); } // generated HTML: <a href="/articles/15"> My new article </a>
  • 13. Things you can do with play Straightforward file upload management // the Java code public static void uploadPhoto(String title, File photo) { ... } // a simple HTML form <form action="@{Article.uploadPhoto()}" method="POST" enctype="multipart/form-data"> <input type="text" name="title" /> <input type="file" id="photo" name="photo" /> <input type="submit" value="Send it..." /> </form>
  • 14. DEMO Let’s create our own web application: a personal agenda