Pergunta

Eu tento copiar os exemplos em wikihttp://wiki.liftweb.net/index.php/hello_darwin

No exemplo de helloform2.scala

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

Sempre imprime

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

Estou fazendo algo errado?

Desculpe por esquecer de postar código completo, já tento o segundo no wiki como abaixo. 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>

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

Agora, o OMS mostra correto na página renderizada, mas o console ainda imprimevalue:hogehoge :: Empty

Estou usando o elevador 1.0

obrigado.

Foi útil?

Solução

Você também deve alterar esse código, como mostrado no exemplo na página do Wiki, que vou copiar aqui:

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

Observe que Whofield é definido de maneira muito diferente.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top