I'd like to make Lift templates an option for any JAXRS developer
who's made a RESTful service and wants nice HTML/XML/Atom views using
Lift snippets etc. A thread recently started on the Jersey list btw...
http://n2.nabble.com/using-Lift-templates-with-Jersey-%28was-Re%3A--Jersey--custom--TemplateProcessor-not-having-its-constructor-injected-%29-td2675518.html
I've started hacking up a Jersey TemplateProcessor to wire in Lift
templates using implicit views; I can grab the template using Lift's
TemplateFinder fine - but I've just not got enough Lift implementation
knowledge yet to figure out how to render it :). I tried using
LiftServlet but thats a bit of a hack and it tends to just return the
template itself (since I'm not using Lifts mapping of URIs to requests
etc) - I kinda need to go in somewhere in between the two :)
FWIW I'm imagining two possible options
(i) folks write Java Resource Beans for JAXRS then wire Lift templates
using the @ImplictProvides mechanism to hook a resource bean to the
Lift template
(ii) folks create markup - or template instantiations within their
JAXRS beans written in Scala then there's no need for the
@ImplicitProvides hook. e.g.
@Path("/bar")
class MyResource {
@GET
@Produces(Array("text/html"))
def view() = <html><body><h1>Hello World!</h1></body></html>
...
@POST
def foo(form: SomeBean) = {...}
}
In either case, I need some little hook to be able to take a
Box[NodeSeq] and pass it to Lift to render it using the standard lift
tags + snippets etc.
This could be a gentle way to get folks gradually hooked on
Scala/Lift; gradually moving from Java/JSP to Scala/Lift for
templates, then resource beans etc. (Changing web frameworks is often
a big decision to make, though switching out JSP and using Lift
templates is a kinda no brainer... :)
I wondered if any Lift ninja's could give me some hints at a clean way
to do this?
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/
By all means, id love to see this work, but it would be a quite a task and
one that involves knowing exactly how lift template pipeline works - good
luck!
Tim
Cool thanks.
BTW I don't much mind about ripping the template stuff out of Lift
into a separate piece - I am totally happy to have
LiftRules/LiftSession, Comet et al there and to keep Lift intact.
I guess all I really want is a way to render a NodeSeq which can
contain <lift:surround> and other arbitrary snippets inside. So all I
really want is another entry point into Lift other than the
filter/servlet where somehow I can do something like this...
LiftServlet.render(xhtml:NodeSeq, out:OutputStream)
which delves into the internal Lift stuff I don't grok in between
LiftServlet and TemplateFinder and does all that cool magic :) I could
pass in a servletRequest/response too if that'd help make the
implementation easier. I realise this could be tricky though with all
that ajax stuff etc.
which delves into the internal Lift stuff I don't grok in between
LiftServlet and TemplateFinder and does all that cool magic :) I could
pass in a servletRequest/response too if that'd help make the
implementation easier. I realise this could be tricky though with all
that ajax stuff etc.
--
Awesome - huge thanks! :)
I was just about to post a patch I'd figured out to implement this in
a way less elegant way; you saved me the trouble :)
I've managed to use this API to provide a basic integration of Lift
templates and Jersey....
http://github.com/jstrachan/liftweb/tree/master/lift-jersey
I'm still working on it to provide some better examples (and
navigation isn't quite working yet), but so far its working pretty
well!
2009/5/13 David Pollak <feeder.of...@gmail.com>:
> Please see:Awesome - huge thanks! :)
>
> S.render(NodeSeq, HttpServletRequest): NodeSeq
I was just about to post a patch I'd figured out to implement this in
a way less elegant way; you saved me the trouble :)
I've managed to use this API to provide a basic integration of Lift
templates and Jersey....
http://github.com/jstrachan/liftweb/tree/master/lift-jersey
I'm still working on it to provide some better examples (and
navigation isn't quite working yet), but so far its working pretty
well!
--
I work with Dan and know him well; but I hack on Jersey - I don't work on CXF.