Wicket - 获取使用scala填充的文本框的值

时间:2013-05-06 00:47:11

标签: scala wicket

我正在尝试检索TextField的值,如下所示:

item.add(new TextField("description", new Model[String]() {
    override def getObject(): String = {
        customer.description = ??? // I don't know how I can get the value here
        return ...
    }
}))

我在ListView中插入了这个TextField,我需要使用TextField值在属性模型中设置它。

由于

1 个答案:

答案 0 :(得分:1)

首先,您需要向服务器发送新值,一种可能的解决方案是使用AjaxFormComponentUpdatingBehavior

val description = new TextField("description", new Model[String])
description.add(new AjaxFormComponentUpdatingBehavior("keyup") {
  protected def onUpdate(target: AjaxRequestTarget) {
    val newValue = description.getDefaultModelObjectAsString
  }
})

我还建议设置Throttling

相关问题