我尝试复制 wiki http://wiki.liftweb.net/index.php/Hello_Darwin中的示例
在 HelloForm2.scala 的例子中
"submit" -> submit(?("Send"), () => {println("value:" + who + " :: " + param("whoField"))}),
它总是打印
value:Full(hogehoge) :: Empty" even if i set the who as "object who extends RequestVar(Full("world"))
我做错了吗?
很抱歉忘记发布完整代码,我已经尝试了 wiki 中的第二个,如下所示。索引.html
<lift:surround with="default" at="content">
<h2>Welcome to your project!</h2>
<lift:HelloWorld.show form="POST">
Hello <hello:who />
<br />
<label for="whoField">Who :</label>
<hello:whoField />
<hello:submit />
</lift:HelloWorld.show>
</lift:surround>
和 HelloWorld.scala
class HelloWorld {
object who extends RequestVar(Full("world"));
def show(xhtml: NodeSeq): NodeSeq ={
bind("hello", xhtml,
"whoField" -> text(who.openOr(""), v => who(Full(v))) % ("size" -> "10") % ("id" -> "whoField"),
"submit" -> submit(?("Send"), () => {println("value:" + who.openOr("") + " :: " + param("whoField"))}),
"who" -> who.openOr("")
)
}
}
现在,谁在呈现的页面中显示正确,但控制台仍然打印
value:hogehoge :: Empty
我正在使用电梯 1.0
谢谢。