Apologize for the noob question... Trying to render JSON and receving a null response. Code proves that the GET is being received from sbt console and that data is not null. Any help would be greatly appreciated ... Using irebug the response is empty and the alert prints "JSON View =null"
My Controller
package bowlerquickstart
import org.bowlerframework.controller.{Controller,FunctionNameConventionRoutes}
import org.bowlerframework.model.{ ParameterMapper, Validations}
import org.bowlerframework.view.{Renderable}
import org.bowlerframework._
/**
*
* extends:
* - Controller: used to construct routes and deal with them by providing functions that respond to routes.
* - ParameterMapper: takes a request and maps any values into beans or other objects.
* - Validations: validation enables the Controller
* - Renderable: allows you to render View Model objects.
*/
class MyController extends Controller with ParameterMapper with Validations with Renderable with FunctionNameConventionRoutes {
// simple, no args render, just renders the root view of /views/GET/index (or http 204 for JSON)
// views are resolved by view-root ("/view" on the classpath by default) + HTTP Method + path,
// in this case /views/GET/index. The ending of the template file (mustache, ssp, jade or scaml) will be auto-resolved in the order mentioned here.
// for named params, the ":" of the Scalatra route definition will be replaced by "_" when looking up on the classpath.
def `GET /users` = {
println("GET RECEIVED") //prints properly to console
Users.findAll.foreach(println) //prints properly to console
render(Users.findAll)
}
}
___________________________________________________
javascript from my html page
defaultAction: function( page ){
if( page ) {
//Once the default action is called we want to construct a link to our restful service
var restfulPageUrl = this.restfulUrl + page //
http://localhost:8080/page //Now we have a url lets get the data
this.loadRestfulData( restfulPageUrl );
}
},
loadRestfulData: function( pageUrl ){
//Load the data in using jQuerys ajax call
$.ajax({
beforeSend: function(req) {
req.setRequestHeader("Accept", "application/json");
},
url: pageUrl,
dataType: 'json',
success: function(data){
alert("JSON View =" + data);
}
});
_____________________________________________________________-
user class
package bowlerquickstart
import collection.mutable.MutableList
case class Users(id: Long, var name: String, var yearBirth: java.lang.Integer)
object Users{
var allUsers = new MutableList[Users]
allUsers += Users(1, "Allan", 2011)
allUsers += Users(2, "Bob", 1997)
def findAll: List[Users] = allUsers.toList
}