David,
Moving CRUDify to the object fixed the compiler error. However, back
on the original menu issue, using TestAccess, as you suggest, still
did not work as expected. The menu item doesn't display. Maybe I'm
missing something important. Sorry to be a bother, but hope you can
help.
Here's my menu code:
def logged:Box[LiftResponse] = if(User.loggedIn_?){
Full(RedirectResponse("/Login"))
}else{
Full(PlainTextResponse("No such location"))
}
val testLogin = TestAccess(() => logged)
override def deleteMenuLoc = Empty
override def createMenuLoc: Box[Menu] =
Full(Menu(Loc("Create "+Prefix, createPath, "Continue...",
locSnippets, LocGroup("company"), testLogin,
Loc.Template(createTemplate))))
On May 13, 4:03 pm, David Pollak <[email protected]>
wrote:
> On Wed, May 13, 2009 at 3:30 PM, glenn <[email protected]> wrote:
>
> > Thanks for the heads-up on the 1.1-SNAPSHOT version, but now, when I
> > compile,
> > I get errors. I don't think this has anything to do with menu
> > redirection, but, I have
> > a Company class defined like so:
>
> CRUDify should be mixed into the Meta object not into th instance class. In
> this case, move CRUDify to object Company.
>
> This was the original intent with CRUDify, but I did not put the proper
> constraints on it in 1.0... I fixed that up in 1.1.
>
>
>
>
>
> > class Company extends LongKeyedMapper[Company] with Address[Company]
> > with IdPK with CRUDify[Long,Company] {
> > ...
>
> > }
>
> > And, this is what my compiler output tells me:
>
> > illegal inheritance; self-type com.exmbly.scala.apbul.model.Company
> > does not conform to net.liftweb.mapper.CRUDify
> > [Long,com.exmbly.scala.apbul.model.Company]'s
> > selftype net.liftweb.mapper.CRUDify
> > [Long,com.exmbly.scala.apbul.model.Company] with
> > com.exmbly.scala.apbul.model.Company with
> > net.liftweb.mapper.KeyedMetaMapper
> > [Long,com.exmbly.scala.apbul.model.Company]
>
> > Was something changed in the definition of Crudify? What do I need to
> > change in my code? The error is a bit confusing.
>
> > Glenn...
>
> > On May 13, 2:58 pm, David Pollak <[email protected]>
> > wrote:
> > > On Wed, May 13, 2009 at 2:19 PM, glenn <[email protected]> wrote:
>
> > > > David,
>
> > > > Pardon my ignorance, but I see a Test case class in the Lift 1.0 api
> > > > for Loc, but not TestAccess, which seems similar.
>
> > > I added TestAccess to 1.1-SNAPSHOT last night.
>
> > > It's possible to write something in 1.0, but it's a lot harder...
> > basically,
> > > you have to write a Snippet and do a custom LocParam.
>
> > > Most of us are on 1.1-SNAPSHOT and the sites I deploy are on 1.1-SNAPSHOT
> > > and there hasn't been an instability due to working on trunk-head that
> > I've
> > > seen.
>
> > > > Glenn...
>
> > > > On May 13, 6:58 am, David Pollak <[email protected]>
> > > > wrote:
> > > > > Glenn,
>
> > > > > I've added another Loc param:
>
> > > > > /**
> > > > > * Allows extra access testing for a given menu location such that
> > > > > * you can build a menu that is displayed but redirects the user to
> > a
> > > > > login
> > > > > * page if they are not logged in
> > > > > */
> > > > > case class TestAccess(func: () => Box[LiftResponse]) extends
> > LocParam
>
> > > > > This will let you write a function that tests access for the page and
> > > > return
> > > > > a RedirectResponse if the user needs to log in. It will not impact
> > the
> > > > > display of the menu item.
>
> > > > > Hope this helps.
>
> > > > > Thanks,
>
> > > > > David
>
> > > > > On Tue, May 12, 2009 at 5:23 PM, glenn <[email protected]> wrote:
>
> > > > > > Hmm,
>
> > > > > > Here's my complete menu list for this LocGroup:
>
> > > > > > def quoteMenu:List[Menu] = {
> > > > > > val groupquote = Menu(Loc("groupquote", List("quote",
> > "group"),
> > > > > > "Group Quote", LocGroup("quote"), loggedIn ))
> > > > > > val businessquote = Menu(Loc("businessquote", List("quote",
> > > > > > "business"), "Commercial Quote", LocGroup("quote")))
> > > > > > val lifequote = Menu(Loc("lifequote", List("quote", "life"),
> > > > > > "Life Ins. Quote", LocGroup("quote")))
> > > > > > val autoquote = Menu(Loc("autoquote", List("quote", "auto"),
> > > > > > "Auto Quote", LocGroup("quote")))
> > > > > > val homequote = Menu(Loc("homequote", List("quote", "home"),
> > > > > > "Homeowners Quote", LocGroup("quote")))
> > > > > > val medicarequote = Menu(Loc("medicarequote", List("quote",
> > > > > > "medicare"), "Medicare Sup. Quote", LocGroup("quote")))
> > > > > > List
>
> > (groupquote,businessquote,lifequote,autoquote,homequote,medicarequote)
> > > > > > }
>
> > > > > > I want to control page access so that whenever the user clicks on
> > one
> > > > > > of the above menu items and isn't logged they are redirected to the
> > > > > > login page. As I understand it, there are no submenus here, only
> > > > > > siblings. Where would I put the loggedIn function to make this
> > work?
>
> > > > > > On May 12, 5:02 pm, David Pollak <[email protected]>
> > > > > > wrote:
> > > > > > > If a top-level menu item is not accessible, then none of its
> > children
> > > > are
> > > > > > > accessible. SiteMap does not display any pages that are
> > > > inaccessible.
>
> > > > > > > In the example, you've got all the menus controlled by the
> > "loggedIn"
> > > > > > If()
> > > > > > > clause and that's blocking access to menu and thus the menu is
> > not
> > > > > > > displayed.
>
> > > > > > > On Tue, May 12, 2009 at 4:54 PM, glenn <[email protected]> wrote:
>
> > > > > > > > I have a menu defined as follows:
>
> > > > > > > > def quoteMenu:List[Menu] = {
> > > > > > > > val groupquote = Menu(Loc("groupquote", List("quote",
> > > > "group"),
> > > > > > > > "Group Quote",loggedIn, LocGroup("quote")))
> > > > > > > > ....More menu items
> > > > > > > > }
>
> > > > > > > > and an If LocParam to check if the user is logged in:
>
> > > > > > > > val loggedIn = If(() => User.loggedIn_?,
> > > > > > > > () => RedirectResponse("/login"))
>
> > > > > > > > When the sitemap is displayed, the menu item is not visible if
> > the
> > > > > > > > user isn't logged in. This is not the behavior
> > > > > > > > expected. The user should be able to click on the menu item and
> > be
> > > > > > > > redirected to the login page.
>
> > > > > > > > Any ideas as to what's going on here. Am I even using the right
> > > > > > > > mechanism to control page access?
>
> > > > > > > > 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
>
> --
> 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 [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
-~----------~----~----~----~------~----~------~--~---