I will use slightly modified Listing 4.7 from the book Exploring Lift to ask my question.
// In Boot.boot:
LiftRules.viewDispatch.append {
case List("Expenses", "recent", acctId, authToken) =>
Left(() => Full(RSSView.recent(acctId, authToken)))
// This is a dispatch via the same LiftView object. The path
// "/Site/news" will match this dispatch because of our dispatch
// method defined in RSSView. The path "/Site/stuff/news" will not
// match because the dispatch will be attempted on List("Site","stuff")
case List("Site") => Right(RSSView)
}
// Define the View object:
object RSSView extends LiftView {
def dispatch = {
case "news" => siteNews
}
def recent(acctId : String, authToken : String)() : NodeSeq = {
// User auth, account retrieval here
...
<lift:surround with="rss" at="content">
<lift:Vote.image />
</lift:surround>
}
// Display a general RSS feed for the entire site
def siteNews() : NodeSeq = { ... }
}
How do I pass acctId from the view function recent into the snippet lift:Vote.image? Thanks.
If you’re attempting to get the acctId and authToekn from boot for a user, this won’t work. Boot only runs when the web application starts up, not once for every user.
You’ll have to set SessionVar’s when the user logs in, or when you detect the autologin cookie, and then access the sessionVar where you need it.