I checked there are many other threads with similar issues but i cannot find what's wrong with this one. The CDI @Named doesn't conflict with @ManagedBean. This is the bean class i'm using.
@Named
@RequestScoped
public class UserBean {
private String name;
public UserBean() {
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String addValuesToFlashAction() {
Flash flash = FacesContext.getCurrentInstance()
.getExternalContext().getFlash();
flash.put("name", name);
return "terms?faces-redirect=true";
}
public void pullValuesFromFlashAction(ComponentSystemEvent e) {
Flash flash = FacesContext.getCurrentInstance()
.getExternalContext().getFlash();
this.name = (String) flash.get(name);
}
...
}
And this is the body of the xhtml index page
<h:body>
<f:metadata>
<f:event type="preRenderView"
listener="#{userBean.pullValuesFromFlashAction}"/>
</f:metadata>
<h:messages/>
<h:form>
Name: <h:inputText value="#{userBean.name}"/>
<h:commandButton value="Register"
action="#{userBean.addValuesToFlashAction()}"/>
</h:form>
</h:body>
When i run this i have /flashIndex.xhtml @12,72 listener="#{userBean.pullValuesFromFlashAction}": Target Unreachable, identifier 'userBean' resolved to null and in glassfish logs it throws a javax.el.PropertyNotFoundException