I am trying to Inject a seam component into another, auto creating it. But for some reason the injected seam component throws NPE.
XHTML
<a4j:commandLink id="cbrModal"
action="#{detailAction.showInformation(1L)}"
reRender="DetailModal"
limitToList="true">
<h:outputText value="text"/>
</a4j:commandLink>
DetailActionBean.java
@Name("detailAction")
public class DetailActionBean implements Serializable {
@In(create = true, required = false)
@Out(required = false)
private RulesValidator rulesValidator;
public void showInformation(long id) {
rulesValidator.setCheckCount(0); // rulesValidator == null here and throws npe
}
)
RulesValidator.java
@AutoCreate
@Name("rulesValidator")
@Scope(ScopeType.SESSION)
public class RulesValidator implements Serializable {
private int checkCount = 0;
public void setCheckCount(int checkCount) {
this.checkCount = checkCount;
}
}
Seam will scan a base package and look for @Name components and then those components are auto wireable. I am supposed to put a seam.properties file (empty) for seam to know which base packages to scan. The module I was working on dint have seam.properties and so RulesValidator was not being scanned and treated as a seam component. Hence autoCreate dint work.