Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-3776

Implement default onConfigure() using optional Predicate

    XMLWordPrintableJSON

Details

    Description

      I would really like to see methods on Component to configure visible and enabled state using a predicate pattern. Ex:

      interface ConfigurationPredicate<T extends Component> extends IDetachable {
      boolean evaluate(T component);
      }
      ...
      DropDownChoice ddc = createDDC(); //my convenience method which sets standard properties, creates a label for the component, and other stuff
      ddc.setVisibility(new ConfigurationPredicate<DropDownChoice>() {
      public boolean evaluate(DropDownChoice component)

      { myOtherComponent.configure(); return (myOtherComponent.isVisibleInHierarchy()); }

      public void detach()

      { myOtherComponent.detach(); }

      });

      Please consider creating an optional field on Component which can hold a visibility predicate and an enabled state predicate. You can see the advantage clearly in the code above: I don't have to inline my convenience method. I would like composition to be used, instead of inheritance, so I don't have to subclass DropDownChoice just to control the visibility.

      Thanks, guys!

      Attachments

        Activity

          People

            ivaynberg Igor Vaynberg
            rmorrisey Russell Morrisey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: