Bera
Bera

Reputation: 1282

Wicket - get the value of a textbox filled using scala

I'm trying to retrieve a value of a TextField as is showed bellow:

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 ...
    }
}))

I have this TextField inserted in a ListView and I need to use the TextField value to set it in a property model.

Thanks

Upvotes: 0

Views: 250

Answers (1)

Alexey Mukas
Alexey Mukas

Reputation: 739

First you need to send a new value to the server, one possible solution is using AjaxFormComponentUpdatingBehavior:

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

I would also recommend to set Throttling.

Upvotes: 1

Related Questions