title: onfocus event getting called recursively in Apache wicket
body: <p>I am understanding how to handle JS events like onfocus and onblur in apache wicket. I have a simple form in which there is a textfield. "onfocus" event on this I am trying to set the textfield to a value. I have observed on running the code  that onfocus is called again and again (recursively it seems). I fail to understand why and what I have done wrong.
  Below is the code :</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org"&gt;
  &lt;head&gt;
  &lt;title&gt;Wicket Examples - component reference&lt;/title&gt;
  &lt;link rel="stylesheet" type="text/css" href="style.css"/&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form wicket:id="form"&gt;
      &lt;INPUT wicket:id="input" type="text" name="input" style="WIDTH: 800px" /&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>Java:</p>
  
  <pre><code>package com.poc.pages;
  
  import org.apache.wicket.ajax.AjaxRequestTarget;
  import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
  import org.apache.wicket.markup.html.WebPage;
  import org.apache.wicket.markup.html.form.ChoiceRenderer;
  import org.apache.wicket.markup.html.form.Form;
  import org.apache.wicket.markup.html.form.TextField;
  import org.apache.wicket.model.Model;
  
  public class IndexPage extends WebPage
  {
  /**
   * Constructor
   */
  
  public IndexPage()
  {
  
      Form form = new Form("form");
  
      TextField&lt;String&gt; TextInput = new TextField&lt;String&gt;("input",Model.of(""));
  
      TextInput.add(new AjaxFormComponentUpdatingBehavior("onfocus"){
  
          @Override
          protected void onUpdate(AjaxRequestTarget target) {
              String thisValue =
                      this.getComponent().getDefaultModelObjectAsString();
              thisValue = "ChangedNormally";
              this.getComponent().setDefaultModelObject("ChangedViaDefaultSetModel");
              target.add(this.getComponent());
              System.out.println("onfocus"+thisValue);
          }
  
      });
  
      form.add(TextInput);
     add(form);
  }
  }
  </code></pre>
  
  <p>When I focus on textfield here, ChangedViaDefaultSetModel is set and on console onfocusChangedNormally gets print continuously. I fail to undertsand few things :</p>
  
  <ol>
  <li>Why does onfocus gets called again and again printing <strong>onfocusChangedNormally</strong> evertytime on console?</li>
  <li>How can I get the value of actual model and not default model.</li>
  <li>WHy does the normal value doesnot get reflected in model whereas on doing setDefaultModel() it works?</li>
  </ol>
  
  <p>Thanks For Help</p>