Hi!
I encounter a strange behaviour with using a Backing-Bean in session-scope
(TabChangeListenerBacking). It stores the selected index of a
panelTabbedPane, which is set by a TabChangeListener.
When I change the tabs, I can see that the TabChangeListener works, because
logging info showed that the TabChangeListenerImpl.processTabChange() and
TabChangeListenerBacking.setSelectedIndex() methods are invoked with the
correct index.
The problem happens when I come back to the panelTabbedPane after leaving it
to a page that isn't contained in the panelTabbedPane. When I come back,
TabChangeListenerBacking.getSelectedIndex() is invoked to receive the
currently selected index, but the value is null.
I don't understand why the selected index is 'null', it had been set to the
real selected index before, as I could see in the logging output. It's like
the TabChangeListenerBacking would forget its state. I tried it with a
primitive int variable instead of the Integer before, and the int had been
'0' instead of 'null', instead of the value that had been set by the
TabChangeListenerImpl.processTabChange() before leaving the panelTabbedPane.
The TabChangeListenerBacking seems to forget its state after leaving the
panelTabbedPane, although it's in session-scope.
Does anybody of you have an idea what's going on? I'm clueless. Please have
a look at the code snippets below.
faces-config:
------------
<managed-bean>
<managed-bean-name>TabChangeListenerBacking</managed-bean-name>
<managed-bean-class>de.fhzw.portal.umfragesystem.view.utils.tabbedPane.TabC
hangeListenerBacking</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
panelTabbedPane:
------------------
<t:panelTabbedPane
selectedIndex="#{TabChangeListenerBacking.selectedIndex}"
serverSideTabSwitch="true">
...
<t:tabChangeListener
type="de.fhzw.portal.umfragesystem.view.utils.tabbedPane.TabChangeLi
stenerImpl" />
</t:panelTabbedPane>
The TabChangeListenerImpl:
---------------------------
public TabChangeListenerImpl() {
this.backing = (TabChangeListenerBacking)BackingBeanManager.lookup(
Constants.TABCHANGE_LISTENER_BACKING);
}
public void processTabChange(TabChangeEvent tabChangeEvent) {
int newIndex = tabChangeEvent.getNewTabIndex();
this.backing.setSelectedIndex(new Integer(newIndex));
}
TabChangeListenerBacking:
--------------------------
private Integer selectedIndex;
public void setSelectedIndex(Integer index) {
this.selectedIndex = index;
}
public Integer getSelectedIndex() {
return this.selectedIndex;
}
Regards,
Matthias