Wicket DropDownChoice 中的分隔符 [英] Separator in a Wicket DropDownChoice

查看:30
本文介绍了Wicket DropDownChoice 中的分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一些明显的方法可以在 Wicket DropDownChoice 的选项列表中添加分隔符?在我的情况下,我使用数据源中的两种类型的域对象填充选择.我想我可以手动将某种虚拟域对象添加到选择列表中,但感觉很丑陋.

Is there some obvious way to add a separator to the list of options in a Wicket DropDownChoice? In my case I'm populating the selection with two types of domain objects from my datasource. I guess I could go and manually add some kind of dummy domain object to the choice list but it feels pretty ugly.

示例:

+---------+-+
| Apple   |▼|
| Orange  +-+
| ------- |
| Carrot  |
| Cucumber|
+---------+

当前代码(没有任何分隔符)看起来像:

Current code (without any separator) looks something like:

EntityModel model = getModel();
List<? extends Produce> foods = foodService.getAllProduce(); 
// getAllProduce() returns first all fruits, then all vegetables
add(new DropDownChoice<Produce>(
    "produceSelect", new PropertyModel<Produce>(model, "favProduce"), foods)
);

推荐答案

参见 http://www.wicket-library.com/wicket-examples-6.0.x/compref/wicket/bookmarkable/org.apache.wicket.examples.compref.SelectPage有源代码"链接.

See http://www.wicket-library.com/wicket-examples-6.0.x/compref/wicket/bookmarkable/org.apache.wicket.examples.compref.SelectPage There is "Source code" link.

这篇关于Wicket DropDownChoice 中的分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆