Should work now.

If not please add a comment to

https://issues.apache.org/jira/browse/TOBAGO-236

Regards

Bernd

Bernd Bohmann wrote:
Hello Helmut,

you are right.
Unfortunatley I could not implement a fix for this before afternoon.

I will send a mail if it's fixed.

H. Swaczinna wrote:
Hello Bernd,

yes, I've checked the tobago-example-demo more than once. I can
provide a simple example to you:

test.jsp:

<%@ taglib uri="http://myfaces.apache.org/tobago/component"; prefix="tc" %><%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f" %><%@ page contentType="text/html;charset=UTF-8" language="java" %><%@ page pageEncoding="UTF-8"
%><f:view
 ><tc:page label="Test" width="200px" height="100px">
<tc:tabGroup switchType="reloadTab" state="#{mainController.selectedTab}"> <tc:tabChangeListener type="de.wlps.ndr.workflow.common.webapp.web.SimpleTabChangeListener"
        binding="#{mainController.tabChangeListener}"/>
      <tc:tab label="Tab1">         <tc:out value="Tab1"/>
</tc:tab> <tc:tab label="Tab2"> <tc:out value="Tab2"/> </tc:tab> <tc:tab label="Tab3"> <tc:out value="Tab3"/>
      </tc:tab>       </tc:tabGroup>
  </tc:page>
</f:view>

MainController.java:

  private TabChangeListener tabChangeListener;

  public TabChangeListener getTabChangeListener() {
    getLog().debug("getTabChangeListener: " + tabChangeListener);
    return tabChangeListener;
  }

  public void setTabChangeListener(TabChangeListener tabChangeListener) {
    getLog().debug("setTabChangeListener: " + tabChangeListener);
    this.tabChangeListener = tabChangeListener;
  }

SimpleTabChangeListener.java:

public class SimpleTabChangeListener implements TabChangeListener {

private static final Log LOG = LogFactory.getLog(SimpleTabChangeListener.class);

  public SimpleTabChangeListener() {
    LOG.debug("SimpleTabChangeListener: " + this);
  }
    public void processTabChange(TabChangeEvent tabChangeEvent) {
LOG.debug("processTabChange: " + this + ", " + tabChangeEvent.getOldState() + " -> " + tabChangeEvent.getNewState());
  }
}

The log:

2007-01-08 23:15:17 http-8080-Processor23 DEBUG - de.wlps.ndr.workflow.gena.webapp.web.MainController:376 - getTabChangeListener: null 2007-01-08 23:15:17 http-8080-Processor23 DEBUG - de.wlps.ndr.workflow.common.webapp.web.SimpleTabChangeListener:13 - SimpleTabChangeListener: [EMAIL PROTECTED] 2007-01-08 23:15:17 http-8080-Processor23 DEBUG - de.wlps.ndr.workflow.gena.webapp.web.MainController:381 - setTabChangeListener: [EMAIL PROTECTED] 2007-01-08 23:15:17 http-8080-Processor23 DEBUG - de.wlps.ndr.workflow.gena.webapp.web.MainController:337 - getSelectedTab: 0 2007-01-08 23:15:19 http-8080-Processor24 DEBUG - de.wlps.ndr.workflow.common.webapp.web.SimpleTabChangeListener:13 - SimpleTabChangeListener: [EMAIL PROTECTED] 2007-01-08 23:15:19 http-8080-Processor24 DEBUG - de.wlps.ndr.workflow.gena.webapp.web.MainController:342 - setSelectedTab: 0 2007-01-08 23:15:19 http-8080-Processor24 DEBUG - de.wlps.ndr.workflow.common.webapp.web.SimpleTabChangeListener:17 - processTabChange: [EMAIL PROTECTED], 0 -> 1 2007-01-08 23:23:59 http-8080-Processor25 DEBUG - de.wlps.ndr.workflow.common.webapp.web.SimpleTabChangeListener:13 - SimpleTabChangeListener: [EMAIL PROTECTED] 2007-01-08 23:23:59 http-8080-Processor25 DEBUG - de.wlps.ndr.workflow.gena.webapp.web.MainController:342 - setSelectedTab: 1 2007-01-08 23:23:59 http-8080-Processor25 DEBUG - de.wlps.ndr.workflow.common.webapp.web.SimpleTabChangeListener:17 - processTabChange: [EMAIL PROTECTED], 1 -> 2

You can see, there's allways a new instance of SimpleTabChangeListener
created and the processTabChange() method is invoked on this new
instance. You can see also, there's no call to setTabChangeListener()
in MainController, except the first one. And no call to
getTabChangeListener() after setTabChangeListener().

Regards
Helmut


Hello Helmut,

can you check the tobago-example-demo and the tabChangeListener example.

The tabChangeListener is only created if the binding doesn't point to a valid reference to a TabChangeListener instance.

Are you using facelets or jsp?

Regards

Bernd

H. Swaczinna wrote:
Hello Bernd!

is the GenaTabChangeListener instance of TabChangeListener?
Yes, of course.

public class GenaTabChangeListener implements TabChangeListener {

With the binding attribute you can point directly to a managed bean.
Do you mean this binding attributte?

       binding="#{mainController.tabChangeListener}"/>

But setTabChangeListener() in my managed bean (mainController) is not called, when a new TabChangeListener instance is created. Only the first time.

Regards
Helmut

H. Swaczinna wrote:
Hello,

I've set in my tabGroup a TabChangeListener

<tc:tabGroup switchType="reloadPage" binding="#{mainController.tabGroup}"
    state="#{mainController.selectedTab}">
<tc:tabChangeListener
type="de.wlps.ndr.workflow.common.webapp.web.GenaTabChangeListener"
      binding="#{mainController.tabChangeListener}"/>

But every time the processTabChange() method is called, a new instance
of GenaTabChangeListener is created. And this instance is not set
via the binding in my backing bean. Even if I create the TabChangeListener in the getTabChangeListener() method, there's always a new one created. So the backing bean doesn't know the TabChangeListener and vice versa. How do I access the backing bean from a TabChangeListener? For example to store data entred in a tab when the user switches to another tab. Is it possible to declare the TabChangeListener as a managed bean in faces-config.xml?

Regards
Helmut



Reply via email to