@FacesConverter(forClass = Corporation.class, value = "personConverter")
public class PersonConverter implements Converter {
@Override
public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String rawValue) {
Corporation result = null;
if (uiComponent instanceof HtmlSelectOneMenu) {
HtmlSelectOneMenu menu = (HtmlSelectOneMenu) uiComponent;
UISelectItems items = (UISelectItems) menu.getChildren().get(0);
List obj = (List) items.getValue();
for (Iterator it = obj.iterator(); it.hasNext();) {
Corporation corpo = (Corporation) it.next();
if (corpo.getId().equals(Long.valueOf(rawValue))) {
result = corpo;
break;
}
}
}