分隔线在门票DropDownChoice [英] Separator in a Wicket DropDownChoice

查看:151
本文介绍了分隔线在门票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.

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

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