In the previous example of Wicket you have learned how to make "Hello World" application in Wicket. In this section of Wicket tutorial we are going to describe you an example to create Ajax auto completer in Wicket.
To create Ajax auto completer wicket application we need three files :
AutoCompleter class extends WebPage. In this example we have created an object of Form and this form further consists of AutoCompleteTextField to create Ajax auto complete text field. Here is the full code of AutoCompleter.java as follows:
AutoCompleter.java
package com.roseindia.wicket;
new AutoCompleteTextField("auto", new Model(""))
|
AutoCompleterApplication calls AutoCompleter class when it returns AutoCompleter class via getHomePage() method. Here is the example code as follows:
AutoCompleterApplication.java
package com.roseindia.wicket;
|
Now in the HTML file the auto completer text field is displayed with the wicket identifier "auto".
AutoCompleter.html
<html>
|
To run this example one more thing you need to do is to create entry of AutoCompleteraApplication in XML file web.xml. Following lines of code is to be written in web.xml
| <filter> <filter-name>AutoCompleterApplication</filter-name> <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class> <init-param> <param-name> applicationClassName </param-name> <param-value> com.roseindia.wicket.AutoCompleterApplication </param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>2</param-value> </init-param> </filter> <filter-mapping> <filter-name> AutoCompleterApplication </filter-name> <url-pattern> /wicket/ajaxauto/* </url-pattern> </filter-mapping> |
Output:



|
Recommend the tutorial |
Ask Questions? Discuss: Auto Completer example in Wicket View All Comments
Post your Comment