[
https://issues.apache.org/jira/browse/WICKET-3776?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13046010#comment-13046010
]
Igor Vaynberg commented on WICKET-3776:
---------------------------------------
i have shown you how to build the predicate approach...
without it you would make all those components (the ones that need their
enableness controlled) fields and have one onconfigure which looks like this:
onconfigure() {
boolean enabled=<figure out value>;
ddc.setEnabled(enabled);
textField.setEnabled(enabled);
factoryOutput.setEnabled(enabled);
}
not too wordy and no subclasses....
> Implement default onConfigure() using optional Predicate
> --------------------------------------------------------
>
> Key: WICKET-3776
> URL: https://issues.apache.org/jira/browse/WICKET-3776
> Project: Wicket
> Issue Type: Improvement
> Components: wicket-core
> Affects Versions: 1.4.17
> Reporter: Russell Morrisey
> Assignee: Igor Vaynberg
> Labels: ConfigurationPredicate, Predicate, component,
> onConfigure, setEnabled, setVisible
>
> 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!
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira