I'm trying to make selectOneMenu working. I've managed it to show select with filter input but everytime I try to write something there everything just dissapear.
Here is code from view:
<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>
Values passed by userBean.supervisors are provided by:
public List<User> getSupervisors() {
if (supervisors == null) {
supervisors = userDao.getUsersByRole(Enums.Roles.SUPERVISOR.getValue());
}
return supervisors;
}
And converter is simple:
@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;
}
}
What interesting if I change p:selectOneMenu to p:selectCheckboxMenu filtering and everything works well.
Checks with this css to show the results:
.ui-selectonemenu-items-wrapper{
height: auto !important;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.