I'm using JSF 2.2 with PrettyFaces 3.3.3 in my Entreprise Application.
I mapped my Bean with Annotations (AdminCompaniesController.java) :
@ManagedBean
@ViewScoped
@URLMappings(mappings={
@URLMapping(id = "admin-companies", pattern = "/admin/companies", viewId = "/admin/companies.jsf")
})
public class AdminCompaniesController implements Serializable {
@EJB
private CompanyService companyService;
private Collection<Company> companies = new ArrayList<>();
Company company;
@PostConstruct
public void init() {
companies = companyService.getAllCompanys();
}
}
In my view, I display a table with the data (companies.xhtml) :
<ui:repeat value="#{adminCompaniesController.companies}" var="company">
<tr>
<td><h:outputText value="#{company.name}" /></td>
</tr>
</ui:repeat>
This works fine, i get 29 companies in the table. But as soon as I name my Bean : @ManagedBean(name = "companiesBean")
, I lose all data. The view displays 0 result.
Does it have to do with the bean scope? Or maybe the EJB injection needs a name too?