You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Martin Grigorov <mg...@apache.org> on 2016/03/11 21:45:32 UTC
Introducing lambda in Wicket components and behaviors
Hi,
I'd like to ask you for your opinion on the following options:
1) introduce java.util.function.Consumer in the existing components and
behaviors
Example:
https://github.com/apache/wicket/blob/lambdas-ajax/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
Pros:
- reuse the same components/behaviors as before
Cons:
- the components/behaviors are no more abstract and the developer may
forget to add implementation, i.e. provide consumer or override #onXyz()
method
2) introduce new components and behaviors
Example:
https://github.com/apache/wicket/blob/lambdas-ajax-L/wicket-core/src/main/java/org/apache/wicket/ajax/LAjaxEventBehavior.java
Pros:
- more cleaner API
Cons:
- yet another class for the same functionality
- a bit uglier name. Whatever name I imagine doesn't sound better than the
name of the original class
3) 2) but in separate module (e.g. wicket-java8)
4) 2) but in WicketStuff project
5) Other ideas ?
Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov
Re: Introducing lambda in Wicket components and behaviors
Posted by Tobias Soloschenko <to...@googlemail.com>.
Hi,
looks even better to me! Cool idea Sven! Static methods like build pattern for lambdas.
kind regards
Tobias
> Am 11.03.2016 um 22:33 schrieb Sven Meier <sv...@meiers.net>:
>
> Hi,
>
> I don't like to add additional classes and/or longer class names. Neither should we deprecate any 'old' solutions.
> I'm not keen on the Component#on(String, AjaxListener) method either.
>
> My idea:
> 3)
>
> public static AjaxEventBehavior lambda(String event, WicketConsumer<AjaxRequestTarget> consumer) {
> return new AjaxEventBehavior(event) {
> @Override
> protected void onEvent(AjaxRequestTarget target)
> {
> consumer.accept(target);
> }
> };
> }
>
> Usage:
>
> public MyPanel(String id) {
> super(id);
>
> label = ...;
> label.add(AjaxEventBehavior.lambda("click", this::onDoAjax);
> }
>
> private void onDoAjax(AjaxRequestTarget target) { ... }
>
>
>
> Sven
>
>
>> On 11.03.2016 21:45, Martin Grigorov wrote:
>> Hi,
>>
>> I'd like to ask you for your opinion on the following options:
>>
>> 1) introduce java.util.function.Consumer in the existing components and
>> behaviors
>> Example:
>> https://github.com/apache/wicket/blob/lambdas-ajax/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
>>
>> Pros:
>> - reuse the same components/behaviors as before
>>
>> Cons:
>> - the components/behaviors are no more abstract and the developer may
>> forget to add implementation, i.e. provide consumer or override #onXyz()
>> method
>>
>> 2) introduce new components and behaviors
>> Example:
>> https://github.com/apache/wicket/blob/lambdas-ajax-L/wicket-core/src/main/java/org/apache/wicket/ajax/LAjaxEventBehavior.java
>>
>> Pros:
>> - more cleaner API
>>
>> Cons:
>> - yet another class for the same functionality
>> - a bit uglier name. Whatever name I imagine doesn't sound better than the
>> name of the original class
>>
>> 3) 2) but in separate module (e.g. wicket-java8)
>>
>> 4) 2) but in WicketStuff project
>>
>> 5) Other ideas ?
>>
>> Martin Grigorov
>> Wicket Training and Consulting
>> https://twitter.com/mtgrigorov
>
Re: Introducing lambda in Wicket components and behaviors
Posted by Martin Grigorov <ma...@gmail.com>.
Pushed it to 'static-factories-for-lambdas' branch.
I remembered of Lambdas class by Martijn for all those, but some of them
are in wicket-extensions and this makes it a bit complicated.
Any help with implementation, tests and docs are welcome!
On Sat, Mar 12, 2016 at 10:56 AM, Martin Grigorov <martin.grigorov@gmail.com
> wrote:
> I'm working on this!
> On Mar 12, 2016 9:14 AM, "Tobias Soloschenko" <
> tobiassoloschenko@googlemail.com> wrote:
>
>> Looking forward to this this in several other components! :-)
>>
>> kind regards
>>
>> Tobias
>>
>> Am 11.03.2016 um 23:03 schrieb Sven Meier <sv...@meiers.net>:
>>
>> >> 'onEvent' ... 'onUpdate' ... 'onUpdateChoice' from AFCCUB.
>> >
>> > Cool 8)
>> >
>> > Sven
>> >
>> >
>> >
>> >> On 11.03.2016 23:00, Martin Grigorov wrote:
>> >>> On Fri, Mar 11, 2016 at 10:33 PM, Sven Meier <sv...@meiers.net> wrote:
>> >>>
>> >>> Hi,
>> >>>
>> >>> I don't like to add additional classes and/or longer class names.
>> Neither
>> >>> should we deprecate any 'old' solutions.
>> >>> I'm not keen on the Component#on(String, AjaxListener) method either.
>> >>>
>> >>> My idea:
>> >>> 3)
>> >>>
>> >>> public static AjaxEventBehavior lambda(String event,
>> >>> WicketConsumer<AjaxRequestTarget> consumer) {
>> >>> return new AjaxEventBehavior(event) {
>> >>> @Override
>> >>> protected void onEvent(AjaxRequestTarget target)
>> >>> {
>> >>> consumer.accept(target);
>> >>> }
>> >>> };
>> >>> }
>> >> I like it!
>> >> The method name could be 'onEvent' though. This way one could import it
>> >> statically together with 'onUpdate' from
>> AjaxFormComponentUpdatingBehavior
>> >> and 'onUpdateChoice' from AFCCUB.
>> >>
>> >>
>> >>> Usage:
>> >>>
>> >>> public MyPanel(String id) {
>> >>> super(id);
>> >>>
>> >>> label = ...;
>> >>> label.add(AjaxEventBehavior.lambda("click", this::onDoAjax);
>> >>> }
>> >>>
>> >>> private void onDoAjax(AjaxRequestTarget target) { ... }
>> >>>
>> >>>
>> >>>
>> >>> Sven
>> >>>
>> >>>
>> >>>
>> >>>> On 11.03.2016 21:45, Martin Grigorov wrote:
>> >>>>
>> >>>> Hi,
>> >>>>
>> >>>> I'd like to ask you for your opinion on the following options:
>> >>>>
>> >>>> 1) introduce java.util.function.Consumer in the existing components
>> and
>> >>>> behaviors
>> >>>> Example:
>> >>>>
>> >>>>
>> https://github.com/apache/wicket/blob/lambdas-ajax/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
>> >>>>
>> >>>> Pros:
>> >>>> - reuse the same components/behaviors as before
>> >>>>
>> >>>> Cons:
>> >>>> - the components/behaviors are no more abstract and the developer may
>> >>>> forget to add implementation, i.e. provide consumer or override
>> #onXyz()
>> >>>> method
>> >>>>
>> >>>> 2) introduce new components and behaviors
>> >>>> Example:
>> >>>>
>> >>>>
>> https://github.com/apache/wicket/blob/lambdas-ajax-L/wicket-core/src/main/java/org/apache/wicket/ajax/LAjaxEventBehavior.java
>> >>>>
>> >>>> Pros:
>> >>>> - more cleaner API
>> >>>>
>> >>>> Cons:
>> >>>> - yet another class for the same functionality
>> >>>> - a bit uglier name. Whatever name I imagine doesn't sound better
>> than the
>> >>>> name of the original class
>> >>>>
>> >>>> 3) 2) but in separate module (e.g. wicket-java8)
>> >>>>
>> >>>> 4) 2) but in WicketStuff project
>> >>>>
>> >>>> 5) Other ideas ?
>> >>>>
>> >>>> Martin Grigorov
>> >>>> Wicket Training and Consulting
>> >>>> https://twitter.com/mtgrigorov
>> >
>>
>
Re: Introducing lambda in Wicket components and behaviors
Posted by Martin Grigorov <ma...@gmail.com>.
I'm working on this!
On Mar 12, 2016 9:14 AM, "Tobias Soloschenko" <
tobiassoloschenko@googlemail.com> wrote:
> Looking forward to this this in several other components! :-)
>
> kind regards
>
> Tobias
>
> Am 11.03.2016 um 23:03 schrieb Sven Meier <sv...@meiers.net>:
>
> >> 'onEvent' ... 'onUpdate' ... 'onUpdateChoice' from AFCCUB.
> >
> > Cool 8)
> >
> > Sven
> >
> >
> >
> >> On 11.03.2016 23:00, Martin Grigorov wrote:
> >>> On Fri, Mar 11, 2016 at 10:33 PM, Sven Meier <sv...@meiers.net> wrote:
> >>>
> >>> Hi,
> >>>
> >>> I don't like to add additional classes and/or longer class names.
> Neither
> >>> should we deprecate any 'old' solutions.
> >>> I'm not keen on the Component#on(String, AjaxListener) method either.
> >>>
> >>> My idea:
> >>> 3)
> >>>
> >>> public static AjaxEventBehavior lambda(String event,
> >>> WicketConsumer<AjaxRequestTarget> consumer) {
> >>> return new AjaxEventBehavior(event) {
> >>> @Override
> >>> protected void onEvent(AjaxRequestTarget target)
> >>> {
> >>> consumer.accept(target);
> >>> }
> >>> };
> >>> }
> >> I like it!
> >> The method name could be 'onEvent' though. This way one could import it
> >> statically together with 'onUpdate' from
> AjaxFormComponentUpdatingBehavior
> >> and 'onUpdateChoice' from AFCCUB.
> >>
> >>
> >>> Usage:
> >>>
> >>> public MyPanel(String id) {
> >>> super(id);
> >>>
> >>> label = ...;
> >>> label.add(AjaxEventBehavior.lambda("click", this::onDoAjax);
> >>> }
> >>>
> >>> private void onDoAjax(AjaxRequestTarget target) { ... }
> >>>
> >>>
> >>>
> >>> Sven
> >>>
> >>>
> >>>
> >>>> On 11.03.2016 21:45, Martin Grigorov wrote:
> >>>>
> >>>> Hi,
> >>>>
> >>>> I'd like to ask you for your opinion on the following options:
> >>>>
> >>>> 1) introduce java.util.function.Consumer in the existing components
> and
> >>>> behaviors
> >>>> Example:
> >>>>
> >>>>
> https://github.com/apache/wicket/blob/lambdas-ajax/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
> >>>>
> >>>> Pros:
> >>>> - reuse the same components/behaviors as before
> >>>>
> >>>> Cons:
> >>>> - the components/behaviors are no more abstract and the developer may
> >>>> forget to add implementation, i.e. provide consumer or override
> #onXyz()
> >>>> method
> >>>>
> >>>> 2) introduce new components and behaviors
> >>>> Example:
> >>>>
> >>>>
> https://github.com/apache/wicket/blob/lambdas-ajax-L/wicket-core/src/main/java/org/apache/wicket/ajax/LAjaxEventBehavior.java
> >>>>
> >>>> Pros:
> >>>> - more cleaner API
> >>>>
> >>>> Cons:
> >>>> - yet another class for the same functionality
> >>>> - a bit uglier name. Whatever name I imagine doesn't sound better
> than the
> >>>> name of the original class
> >>>>
> >>>> 3) 2) but in separate module (e.g. wicket-java8)
> >>>>
> >>>> 4) 2) but in WicketStuff project
> >>>>
> >>>> 5) Other ideas ?
> >>>>
> >>>> Martin Grigorov
> >>>> Wicket Training and Consulting
> >>>> https://twitter.com/mtgrigorov
> >
>
Re: Introducing lambda in Wicket components and behaviors
Posted by Tobias Soloschenko <to...@googlemail.com>.
Looking forward to this this in several other components! :-)
kind regards
Tobias
Am 11.03.2016 um 23:03 schrieb Sven Meier <sv...@meiers.net>:
>> 'onEvent' ... 'onUpdate' ... 'onUpdateChoice' from AFCCUB.
>
> Cool 8)
>
> Sven
>
>
>
>> On 11.03.2016 23:00, Martin Grigorov wrote:
>>> On Fri, Mar 11, 2016 at 10:33 PM, Sven Meier <sv...@meiers.net> wrote:
>>>
>>> Hi,
>>>
>>> I don't like to add additional classes and/or longer class names. Neither
>>> should we deprecate any 'old' solutions.
>>> I'm not keen on the Component#on(String, AjaxListener) method either.
>>>
>>> My idea:
>>> 3)
>>>
>>> public static AjaxEventBehavior lambda(String event,
>>> WicketConsumer<AjaxRequestTarget> consumer) {
>>> return new AjaxEventBehavior(event) {
>>> @Override
>>> protected void onEvent(AjaxRequestTarget target)
>>> {
>>> consumer.accept(target);
>>> }
>>> };
>>> }
>> I like it!
>> The method name could be 'onEvent' though. This way one could import it
>> statically together with 'onUpdate' from AjaxFormComponentUpdatingBehavior
>> and 'onUpdateChoice' from AFCCUB.
>>
>>
>>> Usage:
>>>
>>> public MyPanel(String id) {
>>> super(id);
>>>
>>> label = ...;
>>> label.add(AjaxEventBehavior.lambda("click", this::onDoAjax);
>>> }
>>>
>>> private void onDoAjax(AjaxRequestTarget target) { ... }
>>>
>>>
>>>
>>> Sven
>>>
>>>
>>>
>>>> On 11.03.2016 21:45, Martin Grigorov wrote:
>>>>
>>>> Hi,
>>>>
>>>> I'd like to ask you for your opinion on the following options:
>>>>
>>>> 1) introduce java.util.function.Consumer in the existing components and
>>>> behaviors
>>>> Example:
>>>>
>>>> https://github.com/apache/wicket/blob/lambdas-ajax/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
>>>>
>>>> Pros:
>>>> - reuse the same components/behaviors as before
>>>>
>>>> Cons:
>>>> - the components/behaviors are no more abstract and the developer may
>>>> forget to add implementation, i.e. provide consumer or override #onXyz()
>>>> method
>>>>
>>>> 2) introduce new components and behaviors
>>>> Example:
>>>>
>>>> https://github.com/apache/wicket/blob/lambdas-ajax-L/wicket-core/src/main/java/org/apache/wicket/ajax/LAjaxEventBehavior.java
>>>>
>>>> Pros:
>>>> - more cleaner API
>>>>
>>>> Cons:
>>>> - yet another class for the same functionality
>>>> - a bit uglier name. Whatever name I imagine doesn't sound better than the
>>>> name of the original class
>>>>
>>>> 3) 2) but in separate module (e.g. wicket-java8)
>>>>
>>>> 4) 2) but in WicketStuff project
>>>>
>>>> 5) Other ideas ?
>>>>
>>>> Martin Grigorov
>>>> Wicket Training and Consulting
>>>> https://twitter.com/mtgrigorov
>
Re: Introducing lambda in Wicket components and behaviors
Posted by Sven Meier <sv...@meiers.net>.
> 'onEvent' ... 'onUpdate' ... 'onUpdateChoice' from AFCCUB.
Cool 8)
Sven
On 11.03.2016 23:00, Martin Grigorov wrote:
> On Fri, Mar 11, 2016 at 10:33 PM, Sven Meier <sv...@meiers.net> wrote:
>
>> Hi,
>>
>> I don't like to add additional classes and/or longer class names. Neither
>> should we deprecate any 'old' solutions.
>> I'm not keen on the Component#on(String, AjaxListener) method either.
>>
>> My idea:
>> 3)
>>
>> public static AjaxEventBehavior lambda(String event,
>> WicketConsumer<AjaxRequestTarget> consumer) {
>> return new AjaxEventBehavior(event) {
>> @Override
>> protected void onEvent(AjaxRequestTarget target)
>> {
>> consumer.accept(target);
>> }
>> };
>> }
>>
> I like it!
> The method name could be 'onEvent' though. This way one could import it
> statically together with 'onUpdate' from AjaxFormComponentUpdatingBehavior
> and 'onUpdateChoice' from AFCCUB.
>
>
>> Usage:
>>
>> public MyPanel(String id) {
>> super(id);
>>
>> label = ...;
>> label.add(AjaxEventBehavior.lambda("click", this::onDoAjax);
>> }
>>
>> private void onDoAjax(AjaxRequestTarget target) { ... }
>>
>>
>>
>> Sven
>>
>>
>>
>> On 11.03.2016 21:45, Martin Grigorov wrote:
>>
>>> Hi,
>>>
>>> I'd like to ask you for your opinion on the following options:
>>>
>>> 1) introduce java.util.function.Consumer in the existing components and
>>> behaviors
>>> Example:
>>>
>>> https://github.com/apache/wicket/blob/lambdas-ajax/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
>>>
>>> Pros:
>>> - reuse the same components/behaviors as before
>>>
>>> Cons:
>>> - the components/behaviors are no more abstract and the developer may
>>> forget to add implementation, i.e. provide consumer or override #onXyz()
>>> method
>>>
>>> 2) introduce new components and behaviors
>>> Example:
>>>
>>> https://github.com/apache/wicket/blob/lambdas-ajax-L/wicket-core/src/main/java/org/apache/wicket/ajax/LAjaxEventBehavior.java
>>>
>>> Pros:
>>> - more cleaner API
>>>
>>> Cons:
>>> - yet another class for the same functionality
>>> - a bit uglier name. Whatever name I imagine doesn't sound better than the
>>> name of the original class
>>>
>>> 3) 2) but in separate module (e.g. wicket-java8)
>>>
>>> 4) 2) but in WicketStuff project
>>>
>>> 5) Other ideas ?
>>>
>>> Martin Grigorov
>>> Wicket Training and Consulting
>>> https://twitter.com/mtgrigorov
>>>
>>>
Re: Introducing lambda in Wicket components and behaviors
Posted by Martin Grigorov <mg...@apache.org>.
On Fri, Mar 11, 2016 at 10:33 PM, Sven Meier <sv...@meiers.net> wrote:
> Hi,
>
> I don't like to add additional classes and/or longer class names. Neither
> should we deprecate any 'old' solutions.
> I'm not keen on the Component#on(String, AjaxListener) method either.
>
> My idea:
> 3)
>
> public static AjaxEventBehavior lambda(String event,
> WicketConsumer<AjaxRequestTarget> consumer) {
> return new AjaxEventBehavior(event) {
> @Override
> protected void onEvent(AjaxRequestTarget target)
> {
> consumer.accept(target);
> }
> };
> }
>
I like it!
The method name could be 'onEvent' though. This way one could import it
statically together with 'onUpdate' from AjaxFormComponentUpdatingBehavior
and 'onUpdateChoice' from AFCCUB.
>
> Usage:
>
> public MyPanel(String id) {
> super(id);
>
> label = ...;
> label.add(AjaxEventBehavior.lambda("click", this::onDoAjax);
> }
>
> private void onDoAjax(AjaxRequestTarget target) { ... }
>
>
>
> Sven
>
>
>
> On 11.03.2016 21:45, Martin Grigorov wrote:
>
>> Hi,
>>
>> I'd like to ask you for your opinion on the following options:
>>
>> 1) introduce java.util.function.Consumer in the existing components and
>> behaviors
>> Example:
>>
>> https://github.com/apache/wicket/blob/lambdas-ajax/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
>>
>> Pros:
>> - reuse the same components/behaviors as before
>>
>> Cons:
>> - the components/behaviors are no more abstract and the developer may
>> forget to add implementation, i.e. provide consumer or override #onXyz()
>> method
>>
>> 2) introduce new components and behaviors
>> Example:
>>
>> https://github.com/apache/wicket/blob/lambdas-ajax-L/wicket-core/src/main/java/org/apache/wicket/ajax/LAjaxEventBehavior.java
>>
>> Pros:
>> - more cleaner API
>>
>> Cons:
>> - yet another class for the same functionality
>> - a bit uglier name. Whatever name I imagine doesn't sound better than the
>> name of the original class
>>
>> 3) 2) but in separate module (e.g. wicket-java8)
>>
>> 4) 2) but in WicketStuff project
>>
>> 5) Other ideas ?
>>
>> Martin Grigorov
>> Wicket Training and Consulting
>> https://twitter.com/mtgrigorov
>>
>>
>
Re: Introducing lambda in Wicket components and behaviors
Posted by Sven Meier <sv...@meiers.net>.
Hi,
I don't like to add additional classes and/or longer class names.
Neither should we deprecate any 'old' solutions.
I'm not keen on the Component#on(String, AjaxListener) method either.
My idea:
3)
public static AjaxEventBehavior lambda(String event,
WicketConsumer<AjaxRequestTarget> consumer) {
return new AjaxEventBehavior(event) {
@Override
protected void onEvent(AjaxRequestTarget target)
{
consumer.accept(target);
}
};
}
Usage:
public MyPanel(String id) {
super(id);
label = ...;
label.add(AjaxEventBehavior.lambda("click", this::onDoAjax);
}
private void onDoAjax(AjaxRequestTarget target) { ... }
Sven
On 11.03.2016 21:45, Martin Grigorov wrote:
> Hi,
>
> I'd like to ask you for your opinion on the following options:
>
> 1) introduce java.util.function.Consumer in the existing components and
> behaviors
> Example:
> https://github.com/apache/wicket/blob/lambdas-ajax/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
>
> Pros:
> - reuse the same components/behaviors as before
>
> Cons:
> - the components/behaviors are no more abstract and the developer may
> forget to add implementation, i.e. provide consumer or override #onXyz()
> method
>
> 2) introduce new components and behaviors
> Example:
> https://github.com/apache/wicket/blob/lambdas-ajax-L/wicket-core/src/main/java/org/apache/wicket/ajax/LAjaxEventBehavior.java
>
> Pros:
> - more cleaner API
>
> Cons:
> - yet another class for the same functionality
> - a bit uglier name. Whatever name I imagine doesn't sound better than the
> name of the original class
>
> 3) 2) but in separate module (e.g. wicket-java8)
>
> 4) 2) but in WicketStuff project
>
> 5) Other ideas ?
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
Re: Introducing lambda in Wicket components and behaviors
Posted by Tobias Soloschenko <to...@googlemail.com>.
Less verbose should not take to much influence to naming - like LAEB (it is short but who knows what it stands for) ;-)
kind regards
Tobias
> Am 11.03.2016 um 22:19 schrieb Martin Grigorov <mg...@apache.org>:
>
> Hi Tobias,
>
> On Fri, Mar 11, 2016 at 10:06 PM, Tobias Soloschenko <
> tobiassoloschenko@googlemail.com> wrote:
>
>> Hi Martin,
>>
>> I think option 2 sounds good to me and if this is going to be the
>> preferred way we can set old components to deprecated with a javadoc
>> linking to the new.
>
> For short logic using lambdas is OK, but for something longer I like
> #onXyz() better.
> Something like the following is also fine for my taste:
>
> class MyPanel extends Panel {
>
> public MyPanel(String id) {
> super(id);
>
> add(new LambdaAjaxLink("doAjaxLink", this::onDoAjax));
> }
>
> private void onDoAjax(AjaxRequestTarget target) { ... }
>
> }
>
>
>
>>
>> I would prefer not to use a shortcuts like I for Interface ... -
>> LambdaAjaxEventBehavior is good. :-)
>
> Yes, I've considered this too, but the idea of the lambdas is to be less
> verbose :-)
> That's why I've asked for suggestions.
>
>
>>
>> kind regards
>>
>> Tobias
>>
>>> Am 11.03.2016 um 21:45 schrieb Martin Grigorov <mg...@apache.org>:
>>>
>>> Hi,
>>>
>>> I'd like to ask you for your opinion on the following options:
>>>
>>> 1) introduce java.util.function.Consumer in the existing components and
>>> behaviors
>>> Example:
>> https://github.com/apache/wicket/blob/lambdas-ajax/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
>>>
>>> Pros:
>>> - reuse the same components/behaviors as before
>>>
>>> Cons:
>>> - the components/behaviors are no more abstract and the developer may
>>> forget to add implementation, i.e. provide consumer or override #onXyz()
>>> method
>>>
>>> 2) introduce new components and behaviors
>>> Example:
>> https://github.com/apache/wicket/blob/lambdas-ajax-L/wicket-core/src/main/java/org/apache/wicket/ajax/LAjaxEventBehavior.java
>>>
>>> Pros:
>>> - more cleaner API
>>>
>>> Cons:
>>> - yet another class for the same functionality
>>> - a bit uglier name. Whatever name I imagine doesn't sound better than
>> the
>>> name of the original class
>>>
>>> 3) 2) but in separate module (e.g. wicket-java8)
>>>
>>> 4) 2) but in WicketStuff project
>>>
>>> 5) Other ideas ?
>>>
>>> Martin Grigorov
>>> Wicket Training and Consulting
>>> https://twitter.com/mtgrigorov
>>
Re: Introducing lambda in Wicket components and behaviors
Posted by Martin Grigorov <mg...@apache.org>.
Hi Tobias,
On Fri, Mar 11, 2016 at 10:06 PM, Tobias Soloschenko <
tobiassoloschenko@googlemail.com> wrote:
> Hi Martin,
>
> I think option 2 sounds good to me and if this is going to be the
> preferred way we can set old components to deprecated with a javadoc
> linking to the new.
>
For short logic using lambdas is OK, but for something longer I like
#onXyz() better.
Something like the following is also fine for my taste:
class MyPanel extends Panel {
public MyPanel(String id) {
super(id);
add(new LambdaAjaxLink("doAjaxLink", this::onDoAjax));
}
private void onDoAjax(AjaxRequestTarget target) { ... }
}
>
> I would prefer not to use a shortcuts like I for Interface ... -
> LambdaAjaxEventBehavior is good. :-)
>
Yes, I've considered this too, but the idea of the lambdas is to be less
verbose :-)
That's why I've asked for suggestions.
>
> kind regards
>
> Tobias
>
> > Am 11.03.2016 um 21:45 schrieb Martin Grigorov <mg...@apache.org>:
> >
> > Hi,
> >
> > I'd like to ask you for your opinion on the following options:
> >
> > 1) introduce java.util.function.Consumer in the existing components and
> > behaviors
> > Example:
> >
> https://github.com/apache/wicket/blob/lambdas-ajax/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
> >
> > Pros:
> > - reuse the same components/behaviors as before
> >
> > Cons:
> > - the components/behaviors are no more abstract and the developer may
> > forget to add implementation, i.e. provide consumer or override #onXyz()
> > method
> >
> > 2) introduce new components and behaviors
> > Example:
> >
> https://github.com/apache/wicket/blob/lambdas-ajax-L/wicket-core/src/main/java/org/apache/wicket/ajax/LAjaxEventBehavior.java
> >
> > Pros:
> > - more cleaner API
> >
> > Cons:
> > - yet another class for the same functionality
> > - a bit uglier name. Whatever name I imagine doesn't sound better than
> the
> > name of the original class
> >
> > 3) 2) but in separate module (e.g. wicket-java8)
> >
> > 4) 2) but in WicketStuff project
> >
> > 5) Other ideas ?
> >
> > Martin Grigorov
> > Wicket Training and Consulting
> > https://twitter.com/mtgrigorov
>
Re: Introducing lambda in Wicket components and behaviors
Posted by Tobias Soloschenko <to...@googlemail.com>.
Hi Martin,
I think option 2 sounds good to me and if this is going to be the preferred way we can set old components to deprecated with a javadoc linking to the new.
I would prefer not to use a shortcuts like I for Interface ... - LambdaAjaxEventBehavior is good. :-)
kind regards
Tobias
> Am 11.03.2016 um 21:45 schrieb Martin Grigorov <mg...@apache.org>:
>
> Hi,
>
> I'd like to ask you for your opinion on the following options:
>
> 1) introduce java.util.function.Consumer in the existing components and
> behaviors
> Example:
> https://github.com/apache/wicket/blob/lambdas-ajax/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
>
> Pros:
> - reuse the same components/behaviors as before
>
> Cons:
> - the components/behaviors are no more abstract and the developer may
> forget to add implementation, i.e. provide consumer or override #onXyz()
> method
>
> 2) introduce new components and behaviors
> Example:
> https://github.com/apache/wicket/blob/lambdas-ajax-L/wicket-core/src/main/java/org/apache/wicket/ajax/LAjaxEventBehavior.java
>
> Pros:
> - more cleaner API
>
> Cons:
> - yet another class for the same functionality
> - a bit uglier name. Whatever name I imagine doesn't sound better than the
> name of the original class
>
> 3) 2) but in separate module (e.g. wicket-java8)
>
> 4) 2) but in WicketStuff project
>
> 5) Other ideas ?
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov