0
我試圖做/作者的簡單情況/和獲得提升根據傳入的ID,以建立一個Person對象問題電梯框架 - 與傳遞的URL參數去摘錄類
目前,我有一個作者片段
class Author(item: Person) {
def render = {
val s = item match { case Full(item) => "Name"; case _ => "not found" }
" *" #> s;
}
}
object Author{
val menu = Menu.param[Person]("Author", "Author", authorId => findPersonById(authorId), person => getIdForPerson(person))/"author"
def findPersonById(id:String) : Box[Person] = {
//if(id == "bob"){
val p = new Person()
p.name="Bobby"
p.age = 32
println("findPersonById() id = " +id)
Full(p)
//}else{
//return Empty
//}
}
def getIdForPerson(person:Person) : String = {
return "1234"
}
}
什麼,我試圖做的就是讓代碼來構建一個盒裝的人對象,並把它傳遞到Author類的構造函數。在渲染方法中,我想確定該框是否已滿並根據需要進行。
如果我改變
class Author(item: Person) {
到
class Author(item: Box[Person]) {
它不再起作用,但如果我離開它,因爲它是不再有效,完整(項目)不正確。如果我刪除了val s行,它會起作用(並用item.name替換s)。那麼我該如何做到這一點。謝謝