Apache Wicket - DropDownChoice 实时搜索

Apache Wicket - DropDownChoice live search

我有一个 DropDownChoice 有很多选项。 如何将实时搜索功能添加到 DropDownChoice 以轻松搜索和 select 项?

使用Select2 JavaScript plugin. There is a Wicket integration of Select 2.maven坐标为:

<dependency>
  <groupId>org.wicketstuff</groupId>
  <artifactId>wicketstuff-select2</artifactId>
  <version>8.1.0</version>
</dependency>

Wicket 的 DropDownChoice 生成纯 HTML <select> 元素。对于实时搜索,您需要使用一些 JavaScript 解决方案。

如果您碰巧 use/prefer Bootstrap CSS 框架那么您可能还会发现 https://wb8.teliclab.info/select useful. It is part of wicket-bootstrap-extensions module at https://github.com/l0rdn1kk0n/wicket-bootstrap/tree/wicket-7.x/bootstrap-extensions.