I am very new to CDI and JSF, and I am trying to convert some code from the 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 have a problem. I am trying to convert an example Richfaces tree specifically.
I made the following changes, and I know this is wrong, so do not 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 if this is necessary):
@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 canโt find the right way to replace @ManagedProperty (value = "# {cdsParser.cdsList}") using CDI?
source share