On Tue, Jan 26, 2010 at 1:17 PM, Adam Warski <a...@warski.org> wrote: > Hello, > >> For this you can use loc.link.createPath. I use something similar in >> my codebase. This has a little cruft you may not be precisely >> interested in, but if you look at the link and flink methods, you >> should be able to get an idea of how to use the Loc.Link: > > > I'm using Link in a similar way to, but here I can't use createPath, as > SiteMap.findLoc(...) returns a Loc[_], so the type parameter is unknown, so > without some casts I won't be able to pass the parameter. > > I tried: > > val loc = SiteMap.findLoc("Login").open_! > val link = loc.link.createPath(loc.currentValue.open_!)
Instead of building your Loc inline in the SiteMap declaration and using findLoc, simply declare the loc as a val (with the appropriate type parameter) in Boot or a similar object of your choosing. I have an object I call Site which I use to separate out the Loc stuff from the SiteMap and Menu. Here's what it looks like: object Site { var locs: List[Loc[_]] = Nil def loc(name: String, link: Link[Unit], text: LinkText[Unit], params: AnyLocParam*): Loc[Unit] = { val newLoc = Loc(name, link, text, params: _*) locs = newLoc :: locs newLoc } def uuloc[T <: UUEntity](params: LocParam[T]*)(implicit manifest: Manifest[T]) : UULoc[T] = { val newLoc = new UULoc[T](params.toList) locs = newLoc :: locs newLoc } // Visible locs val home = loc("Home", "index" :: Nil , ?("Home")) val userSearch = loc("User Search", "users" :: "search" :: Nil, ?("User Search")) val orderSearch = loc("Order Search", "orders" :: "search" :: Nil, ?("Order Search")) val orderForm = loc("New Order", "orders" :: "new" :: Nil, ?("New Order")) //... // REST gettable object locs val userDetail = uuloc[User](Hidden) val orderDetail = uuloc[Order](Hidden) //... } Then, in Boot.scala I simply have this: LiftRules.setSiteMap(SiteMap(Site.locs.reverse.map(Menu(_)): _*)) Don't throw away type information when you don't have to! Kris > > but unfortunately the compiler doesn't seem to recognize the fact that the > type parameter for loc is the same as the one returned for loc.currentValue. > > -- > Adam Warski > http://www.warski.org > http://www.softwaremill.eu > > > > > -- > 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. > > -- 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.