我正在尝试通过来自commandButton 的方法操作将对象(模型托管bean 的实例)从jsf 视图传递到控制器托管bean。但是我发现在控制器托管bean中发现传输的对象为空,因此无法以这种方式执行有问题的服务。这是视图的相关部分:
<h:commandLink action="#{employee.delete}" value="Delete account">
<f:setPropertyActionListener target="#{empolyee.emp}" value="#{emp}" />
</h:commandLink>
在这里,控制器托管bean的一部分:
@ManagedBean(name="employee")
@RequestScoped
public class EmployeeController implements Serializable {
private Employee emp = new Employee();
public Employee getEmp() {
return emp;
}
public void setEmp(Employee emp) {
this.emp= emp;
}
public String delete(){
if (this.emp == null) {return "bad";} // The execution stopped here, and the outcome corresponded is returned
else {
employImp.deleteAccount(this.emp);
return "good";
}
}
为什么对象在处理后变为空?谢谢。