I have bean which looks like below:
@ManagedBean(name = "reportDetailsBean")
@ViewScoped
public class ReportDetailsBean implements Serializable {
// content...
}
and JSF page with this part of code:
...
<a4j:queue id="reportQueue" status="globalStatus" />
<a4j:form id="reportForm#{reportDetailsBean.report.id}" ajaxSingle="true" ajaxSubmit="true" eventsQueue="reportQueue" reRender="reportForm" styleClass="">
...
<a4j:outputPanel id="salesItemNameHeader" layout="block" style="cursor: pointer;" rendered="#{reportDetailsBean.model.rowCount gt 0}">
<h:outputText value="#{bundle.reportDetails_salesItem}" />
<rich:spacer width="4px" />
<a4j:support event="onclick" reRender="reportTable" action="#{reportDetailsBean.model['sortTableByColumn']}" status="globalStatus" ajaxSingle="true">
<a4j:actionparam name="columnIndex" value="bySalesItemName" assignTo="#{reportDetailsBean.model['currentSortModelItem']}" />
</a4j:support>
</a4j:outputPanel>
...
JSF page handles param id from URL. Correct adress of this JSF page is for example localhost/reportDetails.jsp?reportId=37
.
Problem occurs when I want open reportDetails.jsp two times - witn different parameters.
There are two scenarios. First one:
1) Open reportDetails.jsp?reportId=1
2) Open reportDetails.jsp?reportId=2
3) reference to ReportDetailsBean
instance from reportDetails.jsp?reportId=1
was changed by reference to ReportDetailsBean
instance from reportDetails.jsp?reportId=2
Second one:
1) Open reportDetails.jsp?reportId=1
2) Click few times on links like is shown above
3) Open reportDetails.jsp?reportId=2
4) Everything is ok - each view has own instance of ReportDetailsBean
Could someone explain me why in the first scenario reference to isntance of backbean is changed?