I defined a RequestScoped bean as below with CDI annotation. I have several pages which use the same bean. When I navigate from page to page. The bean obj keeps the same. Even when I change the session (login wth different user). The bean object is not changed.
According to RequestScoped definition, the bean instance should re-create for each new request. Anything I missed?
I am using JSF/Primefaces. The value input from create.xhtml page can be seen after navigating to detail.xhtml page. In backing bean, the value is not re-assigned.
Thanks,
Zhang
============================================================
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
@Named("targetManager")
@RequestScoped
public class TargetManager implements Serializable {
}
======================================
create.xhtml:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
template="../../templates/rapm.xhtml">
<ui:define name="contents">
<h:form id="createform">
<h:outputLabel id="englishNameLabel">
<h:outputText id="englishName" value="#{msg['view.label.englishname']}:" />
<h:outputText id="englishNameStar" value="* " styleClass="mandatory" />
</h:outputLabel>
<p:inputText id="englishTitle" value="#{targetManager.selectedTarget.englishName}" >
<f:validator id="englishNameValidate1" validatorId="duplicateValidator" />
</p:inputText>`
======================================
detail.xhtml:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
template="../../templates/rapm.xhtml">
<ui:define name="contents">
<p:scrollPanel id="scrollPanel" styleClass="contentPanel ntb" mode="native">
<h:outputText id="englishName" value="#{msg['.view.label.englishname']}:"/>
<h:outputText id="englishNameValue" value="#{targetManager.selectedTarget.englishName}" />
`