Click
  1. Click
  2. CLK-369

Investigate adding ActionListener objet to Controls

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5 M2
    • Fix Version/s: 1.5 M2
    • Component/s: core
    • Labels:
      None

      Description

      Currently the listener registered on Controls is string based.

      While simple to create it is harder to maintain as refactoring cannot be applied when renaming the method.

      An alternative to the string based listener is to introduce a ActionListener object that encapsulates the callback, and a method, AbstractControl.setListener(ActionListener) which registers the listener on the control.

      public class ActionListener {
      public boolean onAction(Control control)

      { return true; }

      }

        Activity

        Henri Yandell made changes -
        Project Import Fri Mar 20 14:11:32 PDT 2009 [ 1237583492744 ]
        Bob Schellink made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Bob Schellink made changes -
        Field Original Value New Value
        Fix Version/s 1.5 M1 [ 10010 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.5 M2 [ 10022 ]
        Resolution Fixed [ 1 ]
        Hide
        Bob Schellink added a comment -

        net.sf.click.ActionListener interface added which supersedes the current String based listener approach.

        Show
        Bob Schellink added a comment - net.sf.click.ActionListener interface added which supersedes the current String based listener approach.
        Hide
        Malcolm Edgar added a comment -

        I presume the use case is:

        button.setActionListener(new ActionListener() {
        public boolean onAction(Control control)

        { // TODO return true; }

        });

        Passing the event source is a good idea. An early version of the string based method did this, but I never used the event source much. However in more complex scenarios you can definitely see the benefit.

        This class could go in the net.sf.click.control or net.sf.click.util package. I think the control package would be the best place.

        regards Malcolm Edgar

        Show
        Malcolm Edgar added a comment - I presume the use case is: button.setActionListener(new ActionListener() { public boolean onAction(Control control) { // TODO return true; } }); Passing the event source is a good idea. An early version of the string based method did this, but I never used the event source much. However in more complex scenarios you can definitely see the benefit. This class could go in the net.sf.click.control or net.sf.click.util package. I think the control package would be the best place. regards Malcolm Edgar
        Bob Schellink created issue -

          People

          • Assignee:
            Bob Schellink
            Reporter:
            Bob Schellink
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development