0
votes

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.

1
Why not make ForwardCaseBacking a @Named bean? - mabi
Check if you have getter a setter for tblCasePersonController in ForwardCaseBacking. If not, try add its. - Vasil Lukach
Did you check the root cause? Property tblCasePersonController for managed bean forwardCaseBacking does not exist. Check that appropriate getter and/or setter methods exist. Basically, you miss the setter method for tblCasePersonController in your ForwardCaseBacking - Xtreme Biker
@VasilLukach. Thanks. I added the getter and setter and it worked fine. - manpikin
@XtremeBiker. Thanks, I think I really did not carefully see what the root cause was telling me to do. After adding the property, it worked fine. Thanks. - manpikin

1 Answers

0
votes

Add setter and optionally a getter for tblCasePersonController in ForwardCaseBacking.