Why the Ajax round-trips for each "keyup" to extract the model's object?
Have you tried to implement just the Save link/button and then look-up the
model object from inside the onClick() method?

In your case it would come from the PropertyModel you use already:

TextField description = new TextField("description",new
PropertyModel[Meeting](meeting, "description"))

change to:

IModel descriptionModel = new
PropertyModel[Meeting](meeting, "description"));
TextField descriptionTextField = new TextField("description",
descriptionModel );

and your link becomes:

private class LinkSave(id: String, meeting: Meeting) extends
AjaxLink[String](id) {

@SpringBean
var meetingMediator: TMeetingMediator = _
  def onClick(target: AjaxRequestTarget) {
    meetingDAO.saveMeeting(descriptionModel.getObject())
  }
}

Unless you want to also update some other element on the screen with each
user key press I really don't think you need the "keyup" listener.

~ Thank you,
   Paul Bors


On Thu, May 9, 2013 at 11:03 PM, Bruno Moura <[email protected]> wrote:

> I'm trying to implement a ListView and in on column of it I added a
> listView, for each line,
> I want to save the data inserted on it and update the model:
>
> I'm implemented the code bellow:
>
> val description = new TextField("description",new
> PropertyModel[Meeting](meeting, "description"))
> description.add(new AjaxFormComponentUpdatingBehavior("keyup") {
>   protected def onUpdate(target: AjaxRequestTarget) {
>     description.getDefaultModelObjectAsString
>   }
> })
>
> item.add(description)
>
> And I added a link for each line of my ListView for save the information in
> database,
> each line is a instance of a model meeting as is showed bellow:
>
> item.add(new LinkSave("save", meeting))
>
> private class LinkSave(id: String, meeting: Meeting) extends
> AjaxLink[String](id) {
>
>     @SpringBean
>     var meetingMediator: TMeetingMediator = _
>
>     setVisible(clickavel.asInstanceOf[Boolean])
>     add(new Label("label", new Model[String]() {
>       override def getObject: String = "Save"
>     }))
>
>     def onClick(target: AjaxRequestTarget) {
>       meetingDAO.saveMeeting(meeting)
>
>     }
>   }
>
>
> But unfortunately the code above doesn't work. It's fail to retrieve the
> value of the text
> field and also to set the attribute description of the Object meeting with
> the value of the text field, so in the database the column description is
> never filled
>
> Someone know where I am doing wrong stuff?
>
> Thanks a lot!
>
>
> Bera
>

Reply via email to