请问如何在转换器中通过此方法返回性别。
我有一个性别实体:
@Entity
public class Gender implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String gender;
还有一个使用 selectItem 来检索所有性别的 managedBean
public List<SelectItem> getGenderNoList() {
List<Gender> genderList;
Gender gender;
List<SelectItem> selectedGender = new ArrayList<SelectItem>();
genderList = appSessionBean.getAllGender();
for(Gender g : genderList) {
SelectItem s = new SelectItem(g.getGender());
selectedGender.add(s);
}
return selectedGender;
}
和一个转换器
public Object getAsObject(FacesContext context, UIComponent component, String value) {
}