I emailed Ross directly and said I did run with -Drun.mode=production. Here's what I'm seeing: 1. If I run with -Drun.mode=production, and I access a not found url, say mysite.com/foobar, then, I *do* see the custom 404 page as expected, but, where I normally see my sitemap I see "No Navigation Defined". 2. If I run *without* that production flag, and I access a not found url, I get a blank white screen that says "The requested page was not defined in your SiteMap, so access was blocked. (This message is displayed in development mode only)".
So #2 is expected, #1 is not. Ross, when you emailed me you said you tried to reproduce this, but I think one difference between your scenario and mine is that on my 404 page I have a sitemap rendered. So instead of what dpp had: LiftRules.uriNotFound.prepend { case _ => XhtmlResponse((<html> <body>Silly goose</body> </ html>), Empty, List("Content-Type" -> "text/ html; charset=utf-8"), Nil, 404, S.ieMode) } I have: // Catch 404s LiftRules.uriNotFound.prepend { case (req, _) => XhtmlTemplateResponse(notFoundNode, 404) } with 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) } } - Alex On Dec 29, 7:49 pm, Ross Mellgren <dri...@gmail.com> wrote: > This is the production run mode thing dpp talked about. Try your app with > -Drun.mode=production > > -Ross > > On Dec 29, 2009, at 7:39 PM, Alex Black wrote: > > > 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 <feeder.of.the.be...@gmail.com> > > 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 <a...@alexblack.ca> 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 <a...@alexblack.ca> 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 lift...@googlegroups.com. > >>> To unsubscribe from this group, send email to > >>> liftweb+unsubscr...@googlegroups.com<liftweb%2bunsubscr...@googlegroups.com> > >>> . > >>> 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 lift...@googlegroups.com. > > To unsubscribe from this group, send email to > > liftweb+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/liftweb?hl=en. -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to lift...@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.