tags:

views:

235

answers:

1

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 print "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.

+1  A: 

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.

Daniel
thanks, i forgot to post full code.And yes, i think it already the same as u said.if i didn't use the lift way and let the textfield have the name "whoFiled", then param("whoField") shows well. but using the liftway in the wiki page, then it generates textfield's name automatically, and param always shows Empty in my code..
koji lin
Looks like param("whoField") get Empty is not a problem.thanks
koji lin