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

        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
        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.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development