Recent Posts
Archives

Posts Tagged ‘JavaWeb’

PostHeaderIcon [DevoxxBE2012] Rapid Application Development with Play 2

Peter Hausel, a core team member of the Play Framework and software engineer at Typesafe, demonstrated the efficiencies of Play 2 for swift web development in both Java and Scala. With a background in web technologies and open source, Peter showcased how Play streamlines workflows, emphasizing live coding to illustrate its features.

He initiated by creating a new Java-based application, highlighting Play’s MVC structure: controllers for logic, views for Scala-based templates, and routes for URL mapping. Peter noted that even Java projects use Scala templates, which require minimal learning akin to JSP.

A key advantage is on-the-fly compilation; changes reload automatically without restarts, accelerating iterations. Peter modified a controller and template, refreshing the browser to see instant updates.

Type-safe templates and routes prevent runtime errors, with compile-time checks ensuring correctness. He integrated front-end tools like CoffeeScript, LESS, and Google Closure Compiler, compiling them seamlessly into production assets.

Peter explored asset management, using RequireJS for modular JavaScript, and reverse routing to generate URLs dynamically, avoiding hardcoding.

For production, he packaged the app into a distributable ZIP, running it standalone. He peeked into running applications via REPL for interactive debugging.

Testing was touched upon, with future scaffolding promised to generate tests easily.

Peter’s demo underscored Play’s design for productivity, blending familiarity with powerful abstractions.

Core Structure and Development Workflow

Peter detailed Play’s layout: app folder houses controllers, views, and assets; conf holds configurations and routes. Routes define HTTP methods, paths, and controllers, supporting parameters for dynamic handling.

In live coding, he added a new route and controller method, demonstrating error handling where compilation failures display directly in the browser, guiding fixes.

Templates use Scala syntax for logic, with type safety catching mismatches early. Peter included layouts via @main, composing reusable structures.

Front-End Integration and Asset Handling

Play compiles CoffeeScript and LESS on-the-fly, minifying with Closure for optimization. Peter added a CoffeeScript file, seeing it transform into JavaScript.

RequireJS integration modularizes scripts, with routes serving them efficiently.

Deployment and Advanced Features

Packaging creates self-contained distributions, runnable via commands. REPL allows inspecting live state.

Peter recapped: routes centralize mapping, auto-reload speeds development, and reverse routing enhances maintainability.

His session positioned Play as a tool for rapid, robust applications.

Links: