title: Wicket: Lazy loading DropDownChoice
body: <p>One DropDownChoice list on my webapp takes very long time to create, because of getting options by some operations with LDAP connection and SQL connection. And because of that the whole page is loading much more than a couple of seconds - I'd say too much.</p>
  
  <p>So what I want to achieve, is to use (best for me) the built-in Ajax functionality of Wicket to lazy load this dropdown, but I have some problems.</p>
  
  <p>I know how to make regular DropDownChoice list, this simple example working great for me - <a href="http://www.mkyong.com/wicket/wicket-dropdown-box-example-dropdownchoice/" rel="nofollow">link</a></p>
  
  <p>I also know how to make lazy-loaded paragraph, from wicket-examples - <a href="http://www.wicket-library.com/wicket-examples-6.0.x/ajax/lazy-loading" rel="nofollow">link</a> (Source Code -> LazyLoadingPage.html/LazyLoadingPage.java)</p>
  
  <p>But putting it together throwing me exceptions and resulting Wicket's Internal error.</p>
  
  <p>Here is how I try to do it:</p>
  
  <p>in HTML:</p>
  
  <pre><code>&lt;select wicket:id="lazy"&gt;&lt;/select&gt;
  </code></pre>
  
  <p>in Java:</p>
  
  <pre><code>private String selected = "abc";
  (...)
  add(new AjaxLazyLoadPanel("lazy") {
  
              @Override
              public Component getLazyLoadComponent(String id) {
                  //simulating long time for simple list
                  try {
                      Thread.sleep(5000);
                  }
                  catch (InterruptedException e) {
                      throw new RuntimeException(e);
                  }
                  return new DropDownChoice&lt;String&gt;(
                          id, new PropertyModel&lt;String&gt;(this,"selected"),
                          Arrays.asList("abc","def"));
  
              }
          });
      }
  </code></pre>
  
  <p>And I'm getting Internal Error from Wicket, with that in logs:</p>
  
  <pre><code>ERROR Unexpected error occurred
  Component [content] (path = [0:lazy:content]) must be applied to a tag of type [select], not:  '&lt;div wicket:id="content"&gt;' (line 0, column 0)
   MarkupStream: [markup = jar:file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%207.0/webapps/devservices/WEB-INF/lib/wicket-extensions-1.5.7.jar!/org/apache/wicket/extensions/ajax/markup/html/AjaxLazyLoadPanel.html
  </code></pre>
  
  <p>, index = 0, current = ''</p>
  
  <p>and stacktrace.</p>
  
  <p>I would really appreciate some help, what I'm doing wrong, or maybe some better code examples.</p>