如何使用rich:inplaceselect从数据库中检索数据

时间:2011-05-09 13:14:21

标签: richfaces

我需要使用rich:inplaceselect显示来自jsp页面的数据,我想将第一个名字和姓氏组合作为富含inplaceselect的值。我的问题是如何在bean中定义选择项?以及什么输入它会是什么?

1 个答案:

答案 0 :(得分:0)

假设你声明你的inplaceSelect正确的方式:

<rich:inplaceSelect value="#{bean.value}" defaultLabel="click to edit">
    <f:selectItems value="#{bean.selectItems}" />
</rich:inplaceSelect>

您的值必须是SelectItems类型,包含值和标签。

// populate your selectitems where you need them, getting your data from 
// your database or somewhere else
List<SelectItem> items = new ArrayList<SelectItem>();
items.add(new SelectItem(...));

像这样访问您的选择项目集合。

public List<SelectItem> getSelectItems() {
    return items;
}