Thanks for pointing that out, the catch-all sounds dangerous. I tried your suggestion, and it works well except I'm encountering one issue, my sitemap renders as "No Navigation Defined." for urls that are not found. I'm using 1.1-M8, I launched jetty in production mode as you indicated, and added the passNotFoundToChain = false.
Did you expect that - or is the passNotFoundToChain meant to solve the sitemap issue? - Alex On Dec 29, 6:10 pm, David Pollak <[email protected]> wrote: > Keep in mind that Lift's behavior for 404s differs between development and > production mode in Lift 1.1-xxx > > To have your app/Lift handle a 404 rather than passing it to your web > container, in Boot.scala: > > LiftRules.passNotFoundToChain = false > > LiftRules.uriNotFound.prepend { > case _ => XhtmlResponse((<html> <body>Silly goose</body> </html>), > Empty, List("Content-Type" -> "text/html; > charset=utf-8"), Nil, 404, S.ieMode) > } > > In development mode, Lift will tell you about SiteMap as this was a common > confusion point among new developers. In production mode, Lift will use > that code. To put Lift in production mode: > > mvn -Drun.mode=production jetty:run > > I would strongly recommend against a "catch-all" entry in SiteMap as it will > expose every page on your site to access. > > > > On Tue, Dec 29, 2009 at 11:17 AM, Alex Black <[email protected]> wrote: > > Ok, I got this working, with 1.1-M8 using S.render. > > > // A node which embeds our 404 template (e.g. 404.html) > > val notFoundNode = > > <lift:embed what="404" /> > > > // Catch 404s > > LiftRules.uriNotFound.prepend { > > case (req, _) => XhtmlTemplateResponse(notFoundNode, 404) > > } > > > // If you're using a sitemap, make sure you have a catch-all item, > > e.g > > // Menu(Loc("Catchall", Pair(Nil, true), "", Hidden :: Nil)) :: > > > using this object: > > > object XhtmlTemplateResponse extends HeaderStuff { > > def apply(nodeToRender: Node, statusCode: Int): LiftResponse = { > > val renderedNode = S.render(nodeToRender, > > S.request.get.request).first > > new XhtmlResponse(renderedNode, Empty, headers, cookies, > > statusCode, false) > > } > > } > > > I think the wiki page: > >http://wiki.liftweb.net/index.php/Setting_up_a_custom_404_page > > should be updated. The current code hides the 404 status code and > > changes the url. > > > I'd offer to write the new wiki page - is there a way for me to get an > > account on that wiki - or is it just for contributors? > > > - Alex > > > On Dec 29, 1:20 pm, Alex Black <[email protected]> wrote: > > > > If you want to display the contents of your 404.html, checkout > > NodeResponse... just load up your template using the template helpers (this > > will give you NodeSeq) and then you can present that back to the user. Job > > done. > > > > I am familiar with NodeResponse and its subclasses. I've used them in > > > our REST api. But, what I can't figure out, is how to use them in > > > conjuction with the templating engine as you seem to be alluding to > > > (with the template helpers). > > > > Can you point me in the right direction? I am going to try switching > > > to M8 and then using S.render like this: > > > > val node404 = <lift:surround with="default" at="content"> > > > <h1>Not Found</h1> > > > </lift:surround> > > > > LiftRules.uriNotFound.prepend { > > > case (req, _) => XhtmlResponse(S.render(node404, req), _, > > > headers, cookies, 404, false) > > > } > > > > > Cheers, Tim > > > > > On 29 Dec 2009, at 15:23, Alex Black wrote: > > > > > > But of course RewriteResponse is not a LiftResponse. Whats the best > > > > > way to do this? Basically I've got a template called 404.html which > > > > > I'd like to display whenever there is a 404. > > > > > > I Just thought of something, perhaps I could add a RewriteRule that > > > > > matches everything? > > > -- > > > You received this message because you are subscribed to the Google Groups > > "Lift" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]<liftweb%[email protected]> > > . > > For more options, visit this group at > >http://groups.google.com/group/liftweb?hl=en. > > -- > Lift, the simply functional web frameworkhttp://liftweb.net > Beginning Scalahttp://www.apress.com/book/view/1430219890 > Follow me:http://twitter.com/dpp > Surf the harmonics -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
