You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Mike Kienenberger (JIRA)" <de...@myfaces.apache.org> on 2006/08/04 16:39:14 UTC

[jira] Commented: (TOMAHAWK-582) Implementation of the TabChangeListenerTag prevents the use of IOC

    [ http://issues.apache.org/jira/browse/TOMAHAWK-582?page=comments#action_12425761 ] 
            
Mike Kienenberger commented on TOMAHAWK-582:
--------------------------------------------

Sounds reasonable to me.

Can you submit this in the form of a patch?
A couple of test cases proving everything still works would be good as well.

> Implementation of the TabChangeListenerTag prevents the use of IOC
> ------------------------------------------------------------------
>
>                 Key: TOMAHAWK-582
>                 URL: http://issues.apache.org/jira/browse/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: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira