Question

i try to copying the examples in wiki http://wiki.liftweb.net/index.php/Hello_Darwin

in the example of HelloForm2.scala

"submit" -> submit(?("Send"), () => {println("value:" + who + " :: " + param("whoField"))}),

It always prints

value:Full(hogehoge) :: Empty" even if i set the who as "object who extends RequestVar(Full("world"))

am i do something wrong?

sorry for forgetting to post full code, i already try the second one in the wiki like below. 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>

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

now, the who shows correct in the rendered page, but console still prints value:hogehoge :: Empty

im using lift 1.0

thanks.

Was it helpful?

Solution

You have to change that code too, as shown in the example in the wiki page, which I'll copy here:

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

Note that whoField is defined very differently.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top