Hey guys, i've been playing around with REST all night, the list, add and delete is working great so far. The problem is, that upon update, it returns me an empty page and doesn't run through the update functionality. Any ideas what the problem in my update method might be?
This is what i got from the samples of the liftweb sources: object Layouts { // Register the Layouts webservice with the dispatcher def init() { LiftRules.dispatch.append(NamedPF("Layouts WebService") { case Req("layouts" :: "list" :: Nil, _, GetRequest) => () => Full(list()) case Req("layouts" :: "add" :: Nil, _, rt) if rt == GetRequest || rt == PostRequest || rt == PutRequest => () => Full(add()) case Req("layouts" :: "update" :: Nil, _, rt) if rt == GetRequest || rt == PostRequest || rt == PutRequest => () => Full(update()) case Req("layouts" :: "delete" :: Nil, _, rt) if rt == GetRequest || rt == PostRequest || rt == DeleteRequest => () => Full(delete()) }) } // List all Layouts as XML def list(): XmlResponse = XmlResponse( <results> { Layout.findAll.map(_.toXml) } </results> ) // extract the parameters, create the layout // return the appropriate response def add(): LiftResponse = (for { name <- S.param("name") ?~ "name parameter missing" layout <- S.param("layout") ?~ "layout content missing" language <- S.param("language") ?~ "language parameter missing" } yield { val l = Layout.create.name(name).layout(layout).language(language) l.save }) match { case Full(success) => XmlResponse(<add success={success.toString}/ >) case Failure(msg, _, _) => NotAcceptableResponse(msg) case _ => NotFoundResponse() } // extract the parameters, create the layout // return the appropriate response def update(): LiftResponse = (for { id <- S.param("id") ?~ "id parameter missing" name <- S.param("name") layout <- S.param("layout") language <- S.param("language") } yield { var l = Layout.findAll(By(Layout.id, id.toLong)).first if (name != "") l.name(name) if (layout != "") l.layout(layout) if (language != "") l.language(language) l.save }) match { case Full(success) => XmlResponse(<update success= {success.toString}/>) case Failure(msg, _, _) => NotAcceptableResponse(msg) case _ => NotFoundResponse() } // extract the parameters, delete the layout // return the appropriate response def delete(): LiftResponse = (for { id <- S.param("id") ?~ "id parameter missing" } yield { Layout.findAll(By(Layout.id, id.toLong)).first.delete_! }) match { case Full(success) => XmlResponse(<delete success= {success.toString}/>) case Failure(msg, _, _) => NotAcceptableResponse(msg) case _ => NotFoundResponse() } } The Idea is to create a Scala/Liftweb based CMS which is administrated over a jQuery Window Interface. So a user can manage everything (and see live-changes on the page) without having an extra Browser-Window for the administration interface open. Authentication isn't builtin yet tho ;) I'll get to that when the bare system is working. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---