Putting it in an "object" won't work, since you probably want the title to
be done per-request.  To clarify what I'm saying, here's a small example of
how I would set the title for an edit page:

First, the template:

<lift:surround at="content">
  <head>
    <title><lift:Info.title /></title>
  </head>

  <lift:Info.edit form="POST" >
    <h1>Type stuff here:</h1>
    <edit:stuff />
    <input type="submit" value="Save" />
  </lift:Info.edit>
</lift:surround>

Then the snippet class:

class Info {
  object toEdit extends RequestVar[Box[InfoStuff]](Empty)

  def title(ignore : NodeSeq) : NodeSeq = Text(toEdit map ("Edit " + _.name)
openOr "No item to edit!")

  def edit (xhtml : NodeSeq) : NodeSeq = ...
}

This assumes that whatever page is redirecting to the edit page will set the
RequestVar, something like:

S.redirectTo("/edit", () => Info.toEdit(Full(someInfoStuffInstance)))

Does that make sense?

Derek

On Wed, Aug 5, 2009 at 11:14 AM, Naftoli Gugenheim <naftoli...@gmail.com>wrote:

>
> You mean the snippet should put its new/edit flag somewhere that the Title
> can read, like a top level object? Then it doesn't need to be an AnyVar
> because it can be set on every request, if Title is processed after the
> snippet in each request--and if not then I don't see how a RequestVar etc.
> would work.
> Seems like it may be more work than the other way, though.
> By the way I sent corrected message afterward--my question was not about
> LocParams but of the items of type ParamType.
>
> -------------------------------------
> Derek Chen-Becker<dchenbec...@gmail.com> wrote:
>
> If you're just looking for a way to programmatically set the title, getting
> into LocParam might be a little bit of overkill. It's probably simpler to
> set up your own SessionVars or RequestVars and access them from the Title
> closure:
>
>
> http://scala-tools.org/scaladocs/liftweb/1.0/net/liftweb/sitemap/Loc/Title.html
>
> Derek
>
> On Wed, Aug 5, 2009 at 9:45 AM, Naftoli Gugenheim <naftoli...@gmail.com
> >wrote:
>
> >
> >
> > -------------------------------------
> > Naftoli Gugenheim<naftoli...@gmail.com> wrote:
> >
> > So what I'm not clear on now is the input to Title. What is a LocParam,
> and
> > how do you you use loc params? What is forceParam, defaultParams, param,
> and
> > foundParam? And in any case how can Title know the value of the
> registered
> > StatefulSnippet's newOrEdit state?
> > Thanks!
> >
> > -------------------------------------
> > David Pollak<feeder.of.the.be...@gmail.com> wrote:
> >
> > On Tue, Aug 4, 2009 at 12:47 PM, Naftoli Gugenheim <naftoli...@gmail.com
> > >wrote:
> >
> > > Maybe my setup is atypical then :)
> > > My default.html is does not have a title tag; instead each view has its
> > > own, relying on head merge.
> > > I don't know if originally I had it in default using lift:Menu.title or
> > > not, but the difficulty with that would be that some pages can be used
> to
> > > edit or add a new item, and the title needs to reflect that.
> >
> >
> > Because the Title() case class takes a function, you can have it do all
> > forms of stuff including looking to the current user, whether you're
> > editing, and "do the right thing".
> >
> >
> > >
> > > So either (1) I need a way that the value of Menu.title will depend on
> > data
> > > in various StatefulSnippets; or (2) make the title ambiguous (add/edit
> > > neutral); or (3) leave the titles in the views and process them with a
> > > function somehow; or (4) put a snippet in the title of every view to
> get
> > the
> > > user.
> > >
> > >
> > >
> > > -------------------------------------
> > > David Pollak<feeder.of.the.be...@gmail.com> wrote:
> > >
> > > On Sun, Aug 2, 2009 at 4:35 PM, Naftoli Gugenheim <
> naftoli...@gmail.com
> > > >wrote:
> > >
> > > >
> > > > How does the Title LocParam work?
> > >
> > >
> > > The Title case class has a function that converts the current object
> > > associated with the Loc into a String representing the title of the
> page
> > > represented by the Loc.
> > >
> > >
> > > >
> > > > Is there a way to modify all titles to e.g. include the logged in
> > user's
> > > > name, without having to edit all the views?
> > >
> > >
> > > The <title> tag is typically defined in the default template.  You
> could
> > > include a snippet in the <title> tag that would contain the user's
> name.
> >  I
> > > would see this as separate from the title of the specific page referred
> > to
> > > by the Loc.Title.
> > >
> > >
> > > >
> > > >
> > > > >
> > > >
> > >
> > >
> > > --
> > > 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
> > >
> > > >
> > >
> >
> >
> > --
> > 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