Question

I'm trying to understand how a basic Lift 2.5 project works. I'm working from the lift_basic application template, and going over the SimplyLift tutorial. When following the tutorial I find that most things seem to work fine, but I'm struggling to understand the why. In particular:

Menu.i("Home") / "index" >> User.AddUserMenusAfter

When I look at the Lift API for Menu, no function i is listed for Menu, nor any function that seems to define /. (This may refer to a function on String, but the API for that seems to only reference / as operating on a token that follows; I'm not sure if i produces a String.) My basic question is; how do I determine what i() is doing, both here in the specific (what is Menu doing at this point in the process) and in general (when I come across a clearly-working function that is not mentioned in the API)?

As an aside, I'm currently using Eclipse as my IDE, with an sbt build that is actually compiling and loading the webapp locally. Eclipse doesn't seem to do a good job of inferring what objects/functions mean, since the build path does not contain the Lift libraries - they're loaded by sbt. Is it possible to make Eclipse aware of these without polluting the repo and maintaining the library configuration in two places?

Was it helpful?

Solution

i is defined in the companion object, not in the actual class. You can see the definition in the source here Menu.i or in the scaladoc:

/**
 * A convenient way to define a Menu item that has the same name as its localized LinkText.
 * <pre>Menu.i("Home") / "index"</pre> is short-hand for <pre>Menu("Home", S.loc("Home", Text("Home")) / "index"</pre>
 */

def i(nameAndLink: String): PreMenu = Menu.apply(nameAndLink, S.loc(nameAndLink, scala.xml.Text(nameAndLink)))

/ is defined as part of PreMenu and it allows you to specify where the menu loc gets served from.

If you are using eclipse, you can try the sbteclipse plugin which should help make eclipse aware of your dependencies.

OTHER TIPS

about the second issue. Did you generate the project structure with SBT? Here's the full info: https://github.com/typesafehub/sbteclipse/

In short, I'd remove anything already-created from the folder and launched eclipse with-source=true After that "imported the project" into eclipse and see it just working.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top