I'm trying to pass an object (instance of a model managed-bean) from a jsf view to a controller managed-bean through a method action from a commandButton. But i found that the object transfered is found null in the controller managed-bean, so the service in question cannot be performed this way. Here's the concerned part of the view :
<h:commandLink action="#{employee.delete}" value="Delete account">
<f:setPropertyActionListener target="#{empolyee.emp}" value="#{emp}" />
</h:commandLink>
And here, the part of the controller managed-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";
}
}
Why the object got null after the process ? Thanks.