background preloader

Play framework 2

Facebook Twitter

Pligor — Integrate Slick 2.0 into Play - the easy and fast way. Play 2 – modules, plugins, what’s the difference? There seems to be some confusion regarding Play 2 modules and plugins.

Play 2 – modules, plugins, what’s the difference?

I imagine this is because the two are often synonymous. In Play (both versions – 1 and 2) there are distinct differences. Hibernate Validator. The XML configuration is closely mirroring the programmatic API.

Hibernate Validator

For this reason it should suffice to just add some comments. default-package is used for all fields where a class name is expected. If the specified class is not fully qualified the configured default package will be used. Every mapping file can then have several bean nodes, each describing the constraints on the entity with the specified class name. A given entity can only be configured once across all configuration files. The same applies for constraint definitions for a given constraint annotation. Setting ignore-annotations to true means that constraint annotations placed on the configured bean are ignored. The nodes class, field, getter, constructor and method (and its sub node parameter) determine on which level the constraint gets placed.

Last but not least, the list of ConstraintValidators associated to a given constraint can be altered via the constraint-definition node. Echo Test. Echo Test The first section of this page will let you do an HTML5 WebSocket test against the echo server.

Echo Test

The second section walks you through creating a WebSocket application yourself. You can also inspect WebSocket messages using your browser. Try it out! This browser supports WebSocket. Does your browsersupport WebSocket? Firefox 17 Linux Uh-oh, the browser you're using doesn't have native support for WebSocket. Play framework and async I/O. A few weeks ago, I had the chance to evaluate the Play framework, a high-productivity Java web framework.

Play framework and async I/O

At LinkedIn, we already use Grails and JRuby/Sinatra, so I was curious how Play would compare. The thing that really caught my eye was Play's support for asynchronous programming, which would be immensely useful for fetching data from our many backend services in parallel and supporting comet-style interactions. Unparsing with ANORM in Play Framework 2 - codemonkey. I recently wrote about how to approach ANORM when parsing SQL results into domain model objects, in most cases you also want to write data to your relational database.

Unparsing with ANORM in Play Framework 2 - codemonkey

The following is one way to do the reversed mapping in a general way and avoiding repeating yourself over and over again. A basic ANORM inserts looks like this: In most simple cases we are not really interested in giving the prepared statement parameters ("id1", "id2") names, so lets use the column names for those: Setting up Apache as a SSL front end for Play. We’ve been using the Play Framework[1] on WellFurnished since the beginning and have been delighted with the results.

Setting up Apache as a SSL front end for Play

If you’re unfamiliar with Play, it’s a Java based MVC framework that allows for rapid application development. I’ve honestly never use a framework that let me get up and running so quickly. Java - How do I install Oracle JDK 6. Scala - Securing REST API on Play framework and OAuth2. Functional Testing with Selenium WebDriver and Scala - Selenium’s WebDriver tools can be used together with Scala, ScalaTest and sbt to create a great functional testing toolkit.

Functional Testing with Selenium WebDriver and Scala -

This will give you the ability to test in various browsers, use a fast “headless” browser and even test iPhone and Android apps and web sites; though I haven’t gotten to mobile testing yet. WebDriver is a set of java libraries providing drivers which pass instructions to the browser allowing you to script control of a web page and verify results. These drivers start up your web browser on your computer and runs the tests; which you can watch as it goes. There are drivers for Firefox, IE, Safari, Chrome and as mentioned above iPhone and Android emulators. One of the great features of controlling a real browser is you can test real user interactions such as AJAX or other complex Javascript. So let’s jump in to some examples and see what capabilities the tools have.

Quick Start How to Run Tests with SBT Start sbt$ sbt Run all tests> test Developing Tests Additional Resources. Playframework 2.0 - How to get the app root path in play2. How to implement a custom PathBindable with Play 2. One thing that IMHO is really cool with Play 2 is how simple the framework is and how easy it is to write highly productive abstractions on top of those provided by the framework.

How to implement a custom PathBindable with Play 2

That allows to start coding simple applications without having to learn a lot of things and to smoothly scale to the development of more complex applications. URL path and query string binders are those kind of scalable abstractions. The framework comes with a minimal set of common supported types (Int, String, etc.) enough to handle general use cases and you can plug your own binders allowing with low effort to handle cases more specific to your project.

For instance, we’ll see in this blog post how to bind business objects from the URL path. It means we’ll be able to define routes like /show/3 to call an action such as the following: The article parameter will automatically be retrieved using the id extracted from the URL path.