在Wicket的五颜六色的下拉式

时间:2012-04-09 11:22:44

标签: select colors wicket

是否有可能在Wicket的下拉菜单中添加彩色物品?下拉列表将从枚举类中获取其值。 例如,enum类具有“红色,黄色,绿色”元素。根据元素,下拉部分将是绿色,红色,黄色。 我该怎么做? 是否可以在DropDownChoice上使用AttributeModifier?

3 个答案:

答案 0 :(得分:3)

请参阅http://www.wicket-library.com/wicket-examples/compref/wicket/bookmarkable/org.apache.wicket.examples.compref.SelectPage

选择组件比DropDownChoice更灵活,但由于每个<选项>使用SelectOption组件,它也会消耗更多内存。

答案 1 :(得分:2)

试试这个......

<style type="text/css">
    OPTION.red{color:red}
    OPTION.yellow{color:yellow}
    OPTION.green{color:green}
</style>

<select id="myselect">
    <option value="1" class="red">red</option>
    <option value="2" class="yellow">yellow</option>
    <option value="3" class="green">green</option>
</select>

答案 2 :(得分:0)

有几种方法,详细on the wiki,可以在呈现时动态添加或更改html标记上的属性。