myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tomasz Stanczak (JIRA)" <>
Subject [jira] Created: (TOMAHAWK-582) Implementation of the TabChangeListenerTag prevents the use of IOC
Date Fri, 04 Aug 2006 10:04:16 GMT
Implementation of the TabChangeListenerTag prevents the use of IOC 

                 Key: TOMAHAWK-582
             Project: MyFaces Tomahawk
          Issue Type: Bug
          Components: Tabbed Pane
    Affects Versions: 1.1.3
         Environment: Windows 2000 SP4, JBoss 4.0.3
            Reporter: Tomasz Stanczak

The TabChangeListenerTag class in its current implementation creates always a new instance
of the application's TabChangeListener implementation. Thus you cannot provide a preinitialized
instance - for example a request configured in faces-config.xml or a Spring bean. Instance
reuse is not possible.

It wants a classname of the TabChangeListener implementation class and creates an instance.
Even given a JSF expression it doesn't get the instance pointed to by the expression but interprets
the expression result as a class name to be instantiated:

                String className;
                if (UIComponentTag.isValueReference(type))
                    FacesContext facesContext = FacesContext.getCurrentInstance();
                    ValueBinding valueBinding = facesContext.getApplication().createValueBinding(type);
                    className = (String) valueBinding.getValue(facesContext);
                } else
                    className = type;
                TabChangeListener listener = (TabChangeListener) ClassUtils.newInstance(className);
                ((HtmlPanelTabbedPane) component).addTabChangeListener(listener);

It could be made better by using something like that:

                    Object refValue = valueBinding.getValue(facesContext);
                    if (refValue instanceof TabChangeListener) {
                        // use the instance found as listener
                    } else {
                        // use the instance found as a class name to be instantiated

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


View raw message