Uploaded image for project: 'MyFaces Tomahawk'
  1. MyFaces Tomahawk
  2. TOMAHAWK-582

Implementation of the TabChangeListenerTag prevents the use of IOC

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1.3
    • 1.1.4-SNAPSHOT
    • Tabbed Pane
    • None
    • Windows 2000 SP4, JBoss 4.0.3

    Description

      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 }

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            mmarinschek Martin Marinschek
            tomasz@rtsoftware.com Tomasz Stanczak
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment