0
我將使用Exploring Lift一書中稍微修改的清單4.7來問我的問題。如何將View中的參數傳遞給Lift中的代碼片段?
// 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 = { ... }
}
我如何通過acctId從視圖功能最近入段電梯:Vote.image?謝謝。
我不想從啓動獲取acctId和authToken。我想從url中獲取acctId,以便我可以渲染不同的內容。但是,SessionVar確實有助於達到這個目的。謝謝。 – coolsuntraveler 2011-12-22 07:43:48