Hi!

I did some further investigations and could limit the possible causes. The
Backing-Bean's selectedIndex property is 'null' only when a Backing-Bean
lookup is performed to read the property value (the Backing-Bean is in
session-scope!).

Example with logging output in the property's setter method (please note the
comments):


public void setSelectedIndex(Integer index) {
    this.selectedIndex = index;

    System.out.println("this.selectedIndex before lookup = " +
this.selectedIndex); // e. g. 1

    TabChangeListenerBacking backing =
(TabChangeListenerBacking)BackingBeanManager.lookup(
      Constants.TABCHANGE_LISTENER_BACKING);  // a reference to this
Backing-Bean

    System.out.println("backing.selectedIndex = " + backing.selectedIndex);
// null

    System.out.println("this.selectedIndex after lookup = " +
this.selectedIndex); // still 1

}


Do you know what might cause this discrepancy? It causes my
panelTabbedPane's selectedIndex memory not to work...



Regards,

Matthias

> -----Ursprüngliche Nachricht-----
> Von: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Auftrag
> von Matthias Kahlau
> Gesendet: Mittwoch, 15. Februar 2006 16:21
> An: Users MyFaces
> Betreff: Problem with panelTabbedPane's selectedIndex memory
>
>
> 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.tabbed
> Pane.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
>

Reply via email to