Skip to content
Ext JS 4.2 Driver for Play Framework 2.2.x
Scala
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
app/com/scalext
conf
project
test/com/scalext/tests
.gitignore
.travis.yml
README.md
build.sbt

README.md

Scalext

Build Status Coverage Status

Ext JS Driver for Play Framework 2.2.2

Features

  • Supports single or batched JSON requests
  • Automatic serialization and deserialization of Ext.Direct actions
  • Direct API configuration using annotations
  • DSL for creating Ext JS objects
  • Parallel execution of batched requests

Roadmap

  • Unit tests
  • Support for more frameworks
  • Expanding DSL

Getting started

Download the latest distributable jar here and put it in your lib folder

Add the classes from which you want to generate a Direct Api to conf/application.conf, for example:

scalext.direct.classes="direct.ProfileForm,direct.RegistrationForm,direct.EchoService"

Include the javascript file which generates the Direct Api inside a view:

<script type="text/javascript" src="@com.scalext.controllers.routes.Api.buildApi()"></script>

The Direct Api is now available!

Configuring the Direct API

Classes can be exposed to the Direct API by adding annotations to methods.

case class Profile(name: String, email: String, company: String)

@Remotable(name = "Scalext.example.Profile")
class Form {

  @Remotable
  def getBasicInfo(): FormResult = {
    var profile = Profile(
      "Roy van Kaathoven",
      "ik@royvankaathoven.nl",
      "Roy")

    FormResult(profile)
  }

  @FormHandler
  def updateBasicInfo(profile: Profile): FormResult = {
    FormResult(
      null,
      errors = Map("name" -> "wrong info"))
  }
}
@Remotable(name = "Scalext.example.Upload")
class Upload {

  @FormHandler
  def uploadFile(post: Any, files: Seq[TemporaryFile]): FormResult = {

    println("Post " + post)
    println("Files " + files)

    FormResult(Map("msg" -> s"${files.size} file(s) succesfully uploaded"))
  }

}

The @Remotable annotation marks a method as Direct Method, which means it will be exposed to the Direct API. By default the method- or classname will be used, this can be overridden by setting the name parameter.

The @FormHandler annotation marks a method as as Form submit handler, which means it can handle form submissions and even file uploads. If the method has to read file uploads then make sure the second parameter can handle the Seq[TemporaryFile] type.

Documentation

Something went wrong with that request. Please try again.