0 Replies Latest reply on Jun 28, 2011 4:38 AM by imcharsi

    hi . about rich:panelToggleListener...

    imcharsi Newbie

      hi

      at first, i'm not native english speaker.

      forgive me even though text is not understandable.

       

      while i study richfaces, i found something strange.

       

      at rich:collapsiblePanel,

      when i put rich:panelToggleListener, write "listener" attribute as follow:

      <rich:collapsiblePanel ... toggleListener="#{...}">

          <rich:panelToggleListener listener="#{...}"/>

      </rich:collapsiblePanel>

       

      in richfaces-4.0.0-Final,

      above code's panelToggleListener doesnt run as my wish.

       

      "toggleListener" call method correctly, but "listener" doesnt call method.

       

      of course, it's possible that developer doesnt implement this function intentionally.

       

      however, i try to solve this problem.

       

      at first, code changes are follow:

       

      =========================

      public class EventListenerHandler ... {

          ...

          protected final TagAttribute listener;

          ...

          EventListenerHandler(TagConfig config) {

              ...

              this.listener = this.getAttribute("listener");

              ...

          }

       

          static public abstract class LazyEventListener ... {

              ...

              protected final MethodExpression listener;

              ...

              protected LazyEventListener(String type, ValueExpression binding, MethodExpression listener) {

                  this(type, binding);

                  this.listener = listener;

              }

              ...

              public void processEvent(FacesEvent event) {

                  ...

                  if(instance == null && this.listener != null)

                      this.listener.invoke(...);

              }

          }

          ...

      }

       

      public class PanelToggleListenerHandler ... {

          ...

          public void applyAttachedObject(...) {

              MethodExpression methodExpression = null;

              ...

              if(this.listener != null) {

                  ...

                  methodExpression = this.listener.getMethodExpression(...);

              }

              ...

              source.addPanelToggleListener(new LazyPanelToggleListener(this.listenerType, expression, methodExpression));

          }

      }

      ===================

       

      i think problem is that tag handler doesnt look up event listener tag's "listener" attribute.

      so i put code that do lookup "listener" attribute.

      and lazyeventlistener has three argument constructor.

      next, in paneltogglelistenerhandler, add lazy listener with three argument that listenerType, binding value expression, and listener method expression.

       

      when i test, it work as my wish.

       

      how do you think about this?