Hi all,I'm putting together a Hello World Lift Module and I ran into a stumbling block which hopefully someone here has the solution to. The problem is this: I'd like to provide a template with my module and have the app using the module correctly find it. Thanks to David's work a few weeks ago I can now add a SiteMap Menu entry referring to my template to the main app's SiteMap from within my module's init method. The template is in my module's src/main/webapp directory. However, when I launch the example app using the module I see the Menu listed correctly but clicking on it leads to a 404 error, as the app doesn't see my template. Do you know how I can tell the app to check my module for the file?
Thanks,Peter--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
Lift ultimately does a ServletContext.getResource (see http://download.oracle.com/docs/cd/E17802_01/products/products/servlet/2.3/javadoc/javax/servlet/ServletContext.html#getResource%28java.lang.String%29 ) on the path of the URL. So, the call will be ServletContext.getResource("/foo/bar.html") and however that gets resolved to your JAR by the J/EE Container is how you have to package the static file.
Alternatively, you can use LiftRules.viewDispatch http://scala-tools.org/mvnsites/liftweb-2.2-RC4/framework/scaladocs/net/liftweb/http/LiftRules$object.html#viewDispatch
You can match on the List[String] representing the path to return Either[() => Box[NodeSeq], LiftView]
Oh, and the comment in TemplateFinder is about programming style... I did some serious turning of findAnyTemplate, I know it's ugly, but it's fast and fast matters.
On Friday, December 24, 2010 3:58:42 PM UTC+1, David Pollak wrote:Lift ultimately does a ServletContext.getResource (see http://download.oracle.com/docs/cd/E17802_01/products/products/servlet/2.3/javadoc/javax/servlet/ServletContext.html#getResource%28java.lang.String%29 ) on the path of the URL. So, the call will be ServletContext.getResource("/foo/bar.html") and however that gets resolved to your JAR by the J/EE Container is how you have to package the static file.
Hmm, ok. Do you know how Jetty works? I'd like to poke around from the sbt console, but I'm not having a lot of luck.
Alternatively, you can use LiftRules.viewDispatch http://scala-tools.org/mvnsites/liftweb-2.2-RC4/framework/scaladocs/net/liftweb/http/LiftRules$object.html#viewDispatch
You can match on the List[String] representing the path to return Either[() => Box[NodeSeq], LiftView]That sounds good, but how would I load the template file from my module's JAR? That seems be the the tricky part, once I can find it I can load it into a NodeSeq, add it to the template cache, all sorts of things.
Oh, and the comment in TemplateFinder is about programming style... I did some serious turning of findAnyTemplate, I know it's ugly, but it's fast and fast matters.
Yep, I know. I just thought it was a good sign that Here Be Dragons. =)In the end I think just using a Template LocParam and setting the template in code is simpler and better for what I want to achieve. That being said, it would still be great if I could do something simple, along the lines of the LiftRules.addToPackages("my.module.name") command I use to enable Lift to find my module's snippets and the like.
Thanks,Peter--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.