0
我有兩個豆DoctorDetailsBean,PatientDetailsBean填充組合框的值,要填充所有醫生的名字組合框在patientRegistration.xhtml無法從數據庫
<h:selectOneMenu value="#{patientDetailsBean.refDr}" style="font-size: medium" >
<f:selectItems value="#{patientDetailsBean.drDetailsbeanList}" var="dr" itemLabel="#{dr.doctorName}" itemValue="#{dr.doctorId}" />
</h:selectOneMenu>
DoctorDetailsBean:
@ManagedBean(name="doctorBean")
@SessionScoped
public class DoctorDetailsBean {
private Long doctorId;
private String doctorName;
private String place;
private Long phoneNumber;
//setters&getters
}
PatientdetailsBean :
@ ManagedBean(name= "patientDetailsBean")
@SessionScoped
public class PatientDetailsBean implements Serializable {
private Long patientId;
private String patientName;
private long refDr;
@ManagedProperty (value ="#{doctorBean}")
private DoctorDetailsBean doctorDetailsBean;
private List<Doctor> drList;
private List<DoctorDetailsBean> drDetailsbeanList;
private PatientDAO patientDAO;
private DoctorDAO doctorDAO;
//setters&getters
public PatientDetailsBean() {
}
@PostConstruct
public void init() throws AppException,AppSysException{
drList = new ArrayList<Doctor>();
drList = doctorDAO.getAllDoctors();
drDetailsbeanList = new ArrayList<DoctorDetailsBean>();
for (Doctor doctor : drList) {
DoctorDetailsBean doctorDetailsBean = new DoctorDetailsBean();
doctorDetailsBean.setDoctorId(doctor.getDoctorId());
doctorDetailsBean.setDoctorName(doctor.getDoctorName());
doctorDetailsBean.setPlace(doctor.getPlace());
doctorDetailsBean.setPhoneNumber(doctor.getPhoneNumber());
drDetailsbeanList.add(doctorDetailsBean);
} }
如何解決我的問題
這是什麼問題?你不知道如何顯示你的drDetailsbeanList作爲selectOneMenu? – Mark