电梯net.liftweb.http.S#param并不像wiki那样工作

时间:2009-07-24 14:56:21

标签: scala lift

我尝试复制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中尝试了第二个,如下所示。 的index.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

感谢。

1 个答案:

答案 0 :(得分:1)

您也必须更改该代码,如维基页面中的示例所示,我将在此处复制:

  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("")
  )

请注意,whoField的定义非常不同。