I'm trying to convert some code from Richfaces 4 showcase to use CDI instead of JSF annotations.
I understand that I can use @Named
to replace @MangedBean
and @Inject
to replace @ManagedProperty
. But I'm having some trouble. I'm trying to convert the RichFaces Tree example specifically.
I have made the following changes and I know this is not correct so please don't use this:
//@ManagedBean
//@ViewScoped
@Named
@SessionScoped
public class TreeBean implements Serializable {
private static final long serialVersionUID = 1L;
// @ManagedProperty(value = "#{cdsParser.cdsList}")
// private List<CDXmlDescriptor> cdXmlDescriptors;
@Inject
private Instance<CDXmlDescriptor> cdXmlDescriptors;
// I also Tried :
// @Inject
// private CDParser cdsParser;
// private List<CDXmlDescriptor> cdXmlDescriptors = cdsParser.getCdsList();
........
Then I added (and I'm not sure this is needed):
@Named
@SessionScoped
public class CDXmlDescriptor implements Serializable { ...
and changed:
//@ManagedBean(name = "cdsParser")
@Named("CDParser")
//@Named
@SessionScoped
public class CDParser implements Serializable{
/**
*
*/
private static final long serialVersionUID = 3890828719623315368L;
@Named
private List<CDXmlDescriptor> cdsList;
I cannot figure out the proper way to replace @ManagedProperty(value = "#{cdsParser.cdsList}")
using CDI?