我在 ManagedBean 中有以下内容
private Employee selectedEmployee; // with getter and setter
public void onRowSelect(SelectEvent event) {
System.out.println("selected employee "+selectedEmployee.getEmployeeNumber());
}
我的问题出在Employee
Entity 类中,如果我employeeNumber
从String
to 开始Long
,我在ManagedBeanselectedEmployee
的方法中得到 nullonRowSelect
员工实体类
private String employeeNumber; // this works
private Long employeeNumber; // this doesn't work
这可能是什么原因?
用于选择的 JSF 代码
<p:dataTable id="dataTable" var="emp" lazy="true"
value="#{myMB.lazyModel}" styleClass="userDataTableStyle"
paginator="true" paginatorPosition="bottom" rows="5"
selection="#{myMB.selectedEmployee}">
<p:ajax event="rowSelectRadio" listener="#{myMB.onRowSelect}"
update=":myform:details" />