Currently I define my app\'s javascript router in a fairly verbose way
def javascriptRoutes = Action { implicit request =>
import routes.javascript._
Ok(R
Also, if you are using Play 2.4, some Classes/packages have been changed:
def javascriptRoutes = Action { implicit request =>
Ok(play.api.routing.JavaScriptReverseRouter("jsRoutes")(routeCache:_*)).as("text/javascript")
}
val routeCache: Array[JavaScriptReverseRoute] = {
import routes._
val jsRoutesClass: Class[javascript] = classOf[routes.javascript]
val controllers = jsRoutesClass.getFields.map(_.get(null))
val met = for (
controller <- controllers;
method <- controller.getClass.getDeclaredMethods if method.getReturnType == classOf[play.api.routing.JavaScriptReverseRoute]
) yield method.invoke(controller).asInstanceOf[play.api.routing.JavaScriptReverseRoute]
met
}