Primefaces selectOneMenu过滤器不起作用

时间:2013-01-27 20:37:10

标签: java primefaces selectonemenu

我正在尝试让selectOneMenu正常工作。我已经设法用过滤器输入显示选择,但每当我尝试写一些东西时,一切都消失了。

以下是来自视图的代码:

<p:selectOneMenu style="width:160px" label="Supervisor" filter="true" filterMatchMode="startsWith" converter="userConverter">
    <f:selectItem itemLabel="Choose..." itemValue="" />
    <f:selectItems value="#{userBean.supervisors}" var="user" itemLabel="#{user.surname} #{user.name}" itemValue="#{user}"/>
</p:selectOneMenu>

userBean.supervisors传递的值由:

提供
public List<User> getSupervisors() {
    if (supervisors == null) {
        supervisors = userDao.getUsersByRole(Enums.Roles.SUPERVISOR.getValue());
    }
    return supervisors;
}

转换器很简单:

@FacesConverter(forClass = User.class, value="userConverter")
public class UserConverter implements Converter {

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
    if(value == "") return null;
    // Convert ProjectDetail to its unique String representation.
    User user = (User) value;
    String idAsString = String.valueOf(user.getUserId());
    return idAsString;
}

@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
    // Convert unique String representation of ProjectDetail back to ProjectDetail object.
    Long id = Long.valueOf(value);
    UserDAO userDao = new UserDAO();
    User user = userDao.getUser(id);
    return user;
}
}

如果我将p:selectOneMenu更改为p:selectCheckboxMenu过滤并且一切正常,那会有什么有趣的事。

1 个答案:

答案 0 :(得分:0)

检查此css以显示结果:

.ui-selectonemenu-items-wrapper{
    height: auto !important;
}