I used the primefaces crud generator in my application, and the Controllers generated are annotated with @Named. I would like to access the a value in the TblCasePersonController from my own created bean ForwardCaseBacking but this gives me an exception as shown below. I tried to change the annotation from @Named to @ManagedBean it still doesn't work.,
This is TblCasePersonController
@Named(value = "tblCasePersonController")
@SessionScoped
public class TblCasePersonController extends AbstractController<TblCasePerson> {
private TblCasePerson selected;
public TblCasePersonController() {
super(TblCasePerson.class);
}
@Override
public TblCasePerson getSelected() {
//Get the selected CasePerson
selected = super.getSelected();
TblCase tblCaseId = new TblCase();
tblCaseId.setId(super.getIdOfSubmittedRecord());
selected.setTblCaseId(tblCaseId);
return selected;
}
This is ForwardCaseBacking
@ManagedBean
@ViewScoped
public class ForwardCaseBacking implements Serializable {
private int caseId;
@ManagedProperty(value="#{tblCasePersonController}")
private TblCasePersonController tblCasePersonController;
@PostConstruct
public void init(){
if(tblCasePersonController.getSelected()!=null){
caseId = tblCasePersonController.getSelected().getId();
}
}
I get this Exception
exception:
javax.servlet.ServletException: Unable to create managed bean forwardCaseBacking. The following problems were found:
- Property tblCasePersonController for managed bean forwardCaseBacking does not exist. Check that appropriate getter and/or setter methods exist.
root cause: com.sun.faces.mgbean.ManagedBeanCreationException: Unable to create managed bean forwardCaseBacking. The following problems were found: - Property tblCasePersonController for managed bean forwardCaseBacking does not exist. Check that appropriate getter and/or setter methods exist.
ForwardCaseBacking
a@Named
bean? - mabitblCasePersonController
inForwardCaseBacking
. If not, try add its. - Vasil LukachProperty tblCasePersonController for managed bean forwardCaseBacking does not exist. Check that appropriate getter and/or setter methods exist.
Basically, you miss the setter method fortblCasePersonController
in yourForwardCaseBacking
- Xtreme Biker