class SomeSnippet {
  implicit def boxOpener(in: Box[NodeSeq]): NodeSeq = in openOr
{S.error("Inactive"); S.redirectTo(S.referer openOr "/")}

  def showA(xhtml: NodeSeq): NodeSeq =
   for {
     id <- S.param("id")
     info <- session1.get(id)
   } yield bind("foo", xhtml, "thing" -> info.x)
}

The implicit makes the Box[NodeSeq] turn into a NodeSeq or redirects the
user.

Thanks,

David

On Sat, May 30, 2009 at 6:12 PM, Bryan <germ...@gmail.com> wrote:

>
> If Foo has 5 methods that I need to show in a Snippet (scattered
> throughout the template), what's a good way to S.error("inactive");
> S.redirectTo("/") whenever Box[Foo] cannot be opened because it is not
> Full, without having to write a bunch of boiler plate code for each of
> the show methods I have defined below.
>
> class SomeSnippet {
>  val foo: Box[Foo] = tryo(session1.get(S.param("id").getOrElse("")))
>
>  def showA(xhtml: NodeSeq): NodeSeq = ...
>  def showB(xhtml: NodeSeq): NodeSeq = ...
>  def showC(xhtml: NodeSeq): NodeSeq = ...
>  def showD(xhtml: NodeSeq): NodeSeq = ...
>  def showE(xhtml: NodeSeq): NodeSeq = ...
> }
>
> Thanks,
> Bryan
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to