David, Glenn,

Many thanks to the thread, I realized how to redirect a user the page
he/she was going to load after his/her logon. In this case, I believe
it's better to re-implement usual IfLoggedIn (instead of overriding
User.login):

lazy val IfLoggedIn = If(User.loggedIn_? _, loginAndComeBack _)

def loginAndComeBack = {
  val uri = S.uri
  RedirectWithState(loginUri, RedirectState( () => User.loginReferer
(uri), ?("notlogged") -> NoticeType.Notice ) )
}

lazy val loginUri = SiteMap.findLoc("Login").map{ _.link.uriList }.
  openOr(LiftRules.siteMapFailRedirectLocation).mkString("/", "/", "")

Alexander

On 19 май, 02:57, David Pollak <feeder.of.the.be...@gmail.com> wrote:
> Glenn,
>
> Sorry... my mistake... the following code works:
>
>   object loginReferer extends SessionVar("/")
>
>   override def homePage = {
>     var ret = loginReferer.*is*
>     loginReferer.remove()
>     ret
>   }
>
>   override def login = {
>     for (r <- S.referer if loginReferer.is == "/") loginReferer.set(r)
>     super.login
>   }
>
> Note the "is" which extracts the contents from the SessionVar before it's
> reset.
>
> On Sun, May 17, 2009 at 10:30 AM, glenn <gl...@exmbly.com> wrote:
>
> > David,
>
> > I was a little puzzled by the line, in the override of def homePage,
> > of loginReferer.remove(). This actually resets the homePage to "/".
> > Removing the line has the intended result. But, then I need a way
> > to reset the loginReferer session variable.
>
> Yeah... the reset happened before the old value was removed from the
> SessionVar.  The above code fixes the problem.
>
>
>
> > Better still, it would be nice to be able to create additional
> > stateful
> > parameter maps, something like Seam's conversation state, which
> > would make creation of wizards a breeze.
>
> There's some of that we StatefulSnippets... seehttp://demo.liftweb.net/arc
>
> I'm hoping that we'll get full wizard support in Lift for 1.1 
> (seehttps://www.lostlake.org/wizard.wmvexcept using a DSL like SiteMap rather
> than XML).
>
>
>
> > This brings up another point. The only way I trust to trace the code
> > to determine what's going on is the old-fashioned way, of putting in
> > a bunch of println statements in my code. With lift's flow back-and-
> > forth
> > between templates, which are really client-side, and snippets, which
> > are on the server, normal java debugging tools just doesn't work.
>
> That's strange.  There's nothing rendered to the client until all the
> template stuff is fully rendered (the templates are processed by the server
> and the snippets are invoked as the <lift:xxx/> tags are encountered during
> the first re-write phase of template process.)
>
> People have had success setting breakpoints in Eclipse, NetBeans and
> IntelliJ in Lift apps.  I use println personally.
>
> Thanks,
>
> David
>
>
>
>
>
> > This makes developing a slow process and can even offset the gains
> > lift brings to coding efficiency.
>
> > What do you, and other's use for debugging that might help.
>
> > Thanks in advance for your assistance.
>
> > Glenn...
>
> > On May 15, 3:35 pm, David Pollak <feeder.of.the.be...@gmail.com>
> > wrote:
> > > In your User object, do the following:
>
> > > object loginReferer extends SessionVar("/")
>
> > > override def homePage = {
> > >   var ret = loginReferer
> > >   loginReferer.remove()
> > >   ret
>
> > > }
>
> > > override def login = {
> > >   for (r <- S.referer if loginReferer.is == "/") loginReferer.set(r)
> > >   super.login
>
> > > }
>
> > > So, we're setting up a session variable the keeps track of the referer to
> > > the login page.
>
> > > We define the homePage method to return this page, but reset after use.
>
> > > And we override the login method to record the referer.
>
> > > On Fri, May 15, 2009 at 3:11 PM, glenn <gl...@exmbly.com> wrote:
>
> > > > I'm using ProtoUser. But even so, I thought that I might have to
> > > > create a
> > > > bunch of separate login pages, each using the loginXhtml form so that
> > > > action={S.uri} would generate the links to match with the cases. In
> > > > that
> > > > way I could do the redirection. But that seems convoluted, to me.
>
> > > > This goes back to using EarlyAccess on a menu item, redirecting to the
> > > > appropriate
> > > > login page, and then once the user logs in, he is immediately taken to
> > > > a new page
> > > > rather than back to "/index". Really, what I'm trying to do is create
> > > > a wizard widget
> > > > or sorts, to perform a sequence of tasks with a finish button on the
> > > > last page.
>
> > > > Glenn...
>
> > > > On May 15, 2:43 pm, David Pollak <feeder.of.the.be...@gmail.com>
> > > > wrote:
> > > > > On your login page, you can capture the referer and then redirect to
> > the
> > > > > refering page on successful login.
>
> > > > > Are you using ProtoUser or are you rolling your own login page?
>
> > > > > On Fri, May 15, 2009 at 1:27 PM, glenn <gl...@exmbly.com> wrote:
>
> > > > > > If I wanted to redirect the user to a different page, depending on
> > > > > > what page they were on when they initiated a login,
> > > > > > does anyone know of a good solution?
>
> > > > > > I'm thinking I need to use a DispatchLocSnippets and define
> > different
> > > > > > dispatch case functions. But I'm not clear how best to go about it?
> > > > > > Would I need different login pages for each case, or is there a
> > > > > > cleaner way in which I can use a single login page for job?
>
> > > > > > Glenn...
>
> > > > > --
> > > > > Lift, the simply functional web frameworkhttp://liftweb.net
> > > > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > > > Follow me:http://twitter.com/dpp
> > > > > Git some:http://github.com/dpp
>
> > > --
> > > Lift, the simply functional web frameworkhttp://liftweb.net
> > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > Follow me:http://twitter.com/dpp
> > > Git some:http://github.com/dpp
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://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