Hi!

Do you have no idea? What can be wrong that a property value accessed by a
reference of a Backing-Bean after a lookup is not the same value than it is
in the accessor method of the Backing-Bean itself?

Please have a look at the example below. I can't find a coding error, so
your general ideas of what might be wrong could really help me...

(The lookup is normally not performed in the accessor method, it's only an
example that shows the value discrepancy. The property value retrieved by a
lookup of the Backing-Bean is 'null' in any case.)


Regards,

Matthias

> -----Ursprüngliche Nachricht-----
> Von: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Auftrag
> von Matthias Kahlau
> Gesendet: Montag, 20. Februar 2006 09:06
> An: MyFaces Discussion
> Betreff: AW: Problem with panelTabbedPane's selectedIndex memory
>
>
> Hi!
>
> Can anybody please share some ideas or guess why the
> selectedIndex property
> value of my session-scoped Backing-Bean TabChangeListenerBacking is
> different when the value is retrieved  by a lookup of the
> Backing-Bean? Any
> help would by highly appreciated...
>
>
> public void setSelectedIndex(Integer index) {
>     this.selectedIndex = index;
>
>     System.out.println("this.selectedIndex before lookup = " +
> this.selectedIndex); // selectedIndex is 1
>
>     // getting a reference to this Backing-Bean
>     FacesContext context = FacesContext.getCurrentInstance();
>     Application app = context.getApplication();
>     ValueBinding binding =
> app.createValueBinding("#{TabChangeListenerBacking}");
>     TabChangeListenerBacking backing =
> (TabChangeListenerBacking)binding.getValue(context);
>
>     System.out.println("backing.selectedIndex = " +
> backing.selectedIndex);
> // selectedIndex is null ?!
>
>     System.out.println("this.selectedIndex after lookup = " +
> this.selectedIndex); // selectedIndex is 1
>
> }
>
>
> Regards,
>
> Matthias
>
>
> > -----Ursprüngliche Nachricht-----
> > Von: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] Auftrag
> > von Matthias Kahlau
> > Gesendet: Samstag, 18. Februar 2006 00:31
> > An: MyFaces Discussion
> > Betreff: AW: Problem with panelTabbedPane's selectedIndex memory
> >
> >
> > 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