background preloader

Play! Framework

Facebook Twitter

Introducing the Play Framework. YAML. Snakeyaml. This documentation is very brief and incomplete.


Feel free to fix or improve it. Installation If you use Maven just add a dependency as described here. If you do not use Maven download the latest JAR and put it to the classpath. Frequently Asked Questions Dictionaries without nested collections are not dumped correctly. Play Framework - Better JSON serialization with FlexJSON. We want to be able to create multiple different JSON views on the same object, to be used in our Play templates.

Play Framework - Better JSON serialization with FlexJSON

This is useful, because entities are often used in several contexts. Declarative model class enhancement in Play. In summary, this article describes a simple example of how to define a Java annotation that will declaratively add behaviour to a model class in a Play framework application.

Declarative model class enhancement in Play

You can do with with a custom annotation and a Play module that enhances the model JavaBean class. Suppose your Play application uses the CRUD module to provide a default user-interface for managing data such as the following JavaBean. public class User extends Model { public String name; public String email; public String address; } Textile. Play! Framework cheat sheet. Controller/link?

Play! Framework cheat sheet

I=32&n=patrickpublic static void link(int i, String n)public static void link(Integer i, String n)public static void link(Long i, String n) Controller/show? Id[0]=1&id[1]=2&id[2]=3&id[3]=4public static void show(Long[] id)public static void show(List. Play framework - Setting up a basic administration area using CRUD. Currently, we have no way to create new blog posts or moderate comments using the blog UI.

Play framework - Setting up a basic administration area using CRUD

Play provides an out of the box CRUD module that will help quickly generate a basic administration area. Enabling the CRUD module A Play application can be assembled from several application modules. This lets you reuse components across several applications or split a large application into several smaller ones. The CRUD module is a generic application that introspects the model classes to create simple lists and forms. To enable the CRUD module, add this line to the /yabe/conf/application.conf file: Overview (Hibernate JavaDocs) Closure (Groovy 1.7.5) Google Group. Caching. To create high-performance systems, sometimes you need to cache data.


Play has a cache library and will use Memcached when used in a distributed environment. If you don’t configure Memcached, Play will use a standalone cache that stores data in the JVM heap. Caching data in the JVM application breaks the “share nothing” assumption made by Play: you can’t run your application on several servers, and expect the application to behave consistently. Ehcache API. Spymemcached - java memcached interface. A simple, asynchronous, single-threaded memcached client written in java.

spymemcached - java memcached interface

Efficient storage of objects. General serializable objects are stored in their serialized form and optionally compressed if they meet criteria. Certain native objects are stored as tightly as possible (for example, a Date object generally consumes six bytes, and a Long can be anywhere from zero to eight bytes). Resilient to server and network outages. Javadocs for spymemcached 2.4.2. Memcached. Module basics. A Play application can be assembled from several application modules.

Module basics

This allows you to reuse application components across several applications or split a large application into several smaller applications. What is a module? A module is just another Play application; however some differences exist in the way resources are loaded for an application module: A module does not have a conf/application.conf file.A module can have a conf/routes file, but these routes will not be loaded automatically.All files are first searched for in the main application path, then in all loaded modules.A module can contain plain Java code packaged as a JAR file in the module/lib directory.Everything in a module is optional. You can create a module with the play new-module command. UnboundID LDAP API. Using UnboundID LDAP SDK. LDAP SDK for Java Using the UnboundID LDAP SDK Persistence Framework The UnboundID LDAP SDK for Java provides a persistence framework that can be used to easily store Java objects in an LDAP directory server.

Using UnboundID LDAP SDK

It uses Java annotations to indicate the way that the information should be stored in the directory, and includes support for add, delete, modify, and search operations. It also provides tools that can be used to generate Java source code from LDAP schema, or to generate LDAP schema from properly-annotated source code. The entries generated by the LDAP SDK persistence framework are constructed in a user-friendly form that is suitable for use by virtually any kind of LDAP client. The following pages provide information about the LDAP SDK persistence framework: LDAP Connection Pools with StartTLS. Com.unboundid.ldap.sdk Class StartTLSPostConnectProcessor java.lang.Object com.unboundid.ldap.sdk.StartTLSPostConnectProcessor All Implemented Interfaces: PostConnectProcessor.

LDAP Connection Pools with StartTLS

Javassist API. Javassist Tutorial. Getting Started with Javassist Shigeru Chiba. YAML Quickstart. YAML Reference. Logging configuration. The Play logger is built on Log4j. Since most Java libraries use Log4j or a wrapper able to use Log4j as a backend, you can easily configure logging that is well-suited to your application. Log4j 1.2.16 API. Java extensions. Java extensions add convenience methods to objects for use in view templates, making expressions more expressive. The code examples show an example template expression, with its result on the next line. Collection extensions join(separator) Concatenates the collection’s entries, with the given separator between each entry. Returns: String. ${['red', 'green', 'blue'].join('/')} red/green/blue pluralize() Returns an ‘s’ when the collection’s size is not 1.

Colour${['red', 'green', 'blue'].pluralize()} colours pluralize(plural) Returns the given plural when the collection’s size is not 1. Box${['red', 'green', 'blue'].pluralize('es')} boxes pluralize(singular, plural) Java 6 API. Deployment. Play applications can be deployed virtually anywhere: inside Servlet containers, as standalone servers, in Google Application Engine, Stack, a Cloud, etc... Standalone Play applications The simplest and the more robust way is to simply run your Play application without any container. You can use a frontal HTTP server like Lighttpd or Apache if you need more advanced HTTP features like virtual hosting. The built-in HTTP server can serve thousands of HTTP requests per second so it will never be the performance bottleneck. Moreover it uses a more efficient threading model (where a Servlet container uses 1 thread per request). Those servers support long polling and allow to manage very long requests (waiting for a long task to complete), and direct streaming of File objects (and any InputStream if you specify the Content-Length), without blocking the execution thread.

Please refer to the 'Put your application in production' page for more information. GlassFish. Google App Engine. Gae module. Moving to production. Testing. Selenium Documentation. ReST. Representational State Transfer (REST) is a software architecture style consisting of guidelines and best practices for creating scalable web services.[1][2] REST is a coordinated set of constraints applied to the design of components in a distributed hypermedia system that can lead to a more performant and maintainable architecture.[3] REST has gained widespread acceptance across the Web[citation needed] as a simpler alternative to SOAP and WSDL-based Web services. RESTful systems typically, but not always, communicate over the Hypertext Transfer Protocol with the same HTTP verbs (GET, POST, PUT, DELETE, etc.) used by web browsers to retrieve web pages and send data to remote servers.[3] The REST architectural style was developed by W3C Technical Architecture Group (TAG) in parallel with HTTP 1.1, based on the existing design of HTTP 1.0.[4] The World Wide Web represents the largest implementation of a system conforming to the REST architectural style.

Architectural properties[edit] How Comet works in Play! Comet. Comet is a web application model in which a long-held HTTP request allows a web server to push data to a browser, without the browser explicitly requesting it.[1][2] Comet is an umbrella term, encompassing multiple techniques for achieving this interaction. All these methods rely on features included by default in browsers, such as JavaScript, rather than on non-default plugins. The Comet approach differs from the original model of the web, in which a browser requests a complete web page at a time.[3] The use of Comet techniques in web development predates the use of the word Comet as a neologism for the collective techniques. Models. JPA Annotations. Template syntax. Play has an efficient templating system which allows to dynamically generate HTML, XML, JSON or any text-based formatted document.

The template engine uses Groovy as an expression language. Template tags. These are the built-in tags that are available in addition to the core template engine syntax. Implicit Objects in templates. Play has an efficient templating system which allows to dynamically generate HTML, XML, JSON or any text-based formatted document. The template engine uses Groovy as an expression language.

Controllers. Implicit Objects in Controllers. RenderJson. Gson User Guide. GSON API. Play! API. Getting Started. Dev Roadmap. Submitting Patches. Coding style guide. Learning Scala. Scala module documentation. Getting Started Guide. OVal 1.61 API. OVal - Object Validation.

This is what power's the Play! framework's validation – keester81

jQuery API. JavaScript Micro-Templating. jQuery UI.