You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Douglas Ferguson <th...@gmail.com> on 2012/06/19 20:58:49 UTC

Wicket Events

Anybody have a good pattern for using Events without having lots of instanceOf, if/else, or switch statements?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket Events

Posted by Douglas Ferguson <th...@gmail.com>.
This seems similar to the google EventBus approach.

On Jun 19, 2012, at 2:58 PM, Jeremy Thomerson wrote:

> Have we talked about adding an IEventDispatcher that dispatches events by
> their class type based on event method signature?
> 
> Example:
> 
> class MyComponent {
> 
> @EventListener // or some annotation
> public void onUserAddedEvent(UserAddedEvent event) {
>  // do something here
> }
> 
> }
> 
> Then when someone calls sink(new UserAddedEvent()) it gets dispatched to
> only those methods that take a UserAddedEvent as their method argument?
> 
> Would that be useful (it seems like it to me - it avoids the instanceof
> checks)?  Am I off track?  Is there something like this or better already
> built?
> 
> An alternative would be that the annotation could take an argument of event
> class(es) that it want's to be notified of.
> 
> 
> 
> 
> -- 
> Jeremy Thomerson
> http://wickettraining.com
> *Need a CMS for Wicket?  Use Brix! http://brixcms.org*
> 
> 
> 
> On Tue, Jun 19, 2012 at 2:36 PM, Igor Vaynberg <ig...@gmail.com>wrote:
> 
>> 
>> http://grepcode.com/file/repo1.maven.org/maven2/org.apache.wicket/wicket-core/6.0.0-beta1/org/apache/wicket/EventDispatcherTest.java#EventDispatcherTest
>> 
>> -igor
>> 
>> On Tue, Jun 19, 2012 at 12:31 PM, Douglas Ferguson <th...@gmail.com>
>> wrote:
>>> Where's the source repository located?
>>> 
>>> 
>>> On Jun 19, 2012, at 2:20 PM, Martin Grigorov wrote:
>>> 
>>>> See org.apache.wicket.EventDispatcherTest in wicket-core's tests
>>>> 
>>>> On Tue, Jun 19, 2012 at 9:58 PM, Douglas Ferguson <th...@gmail.com>
>> wrote:
>>>>> Anybody have a good pattern for using Events without having lots of
>> instanceOf, if/else, or switch statements?
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>> 
>>>> 
>>>> 
>>>> 
>>>> --
>>>> Martin Grigorov
>>>> jWeekend
>>>> Training, Consulting, Development
>>>> http://jWeekend.com
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>> 
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
>> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket Events

Posted by Martin Grigorov <mg...@apache.org>.
This is what the test shows partially.
The test shows the usage of a custom annotation, but doesn't do the
additional step of checking the argument type.

At my job we use such implementation and it works for us.

What you miss this way is the IEvent API - like stopping the event, for example.
Additionally you will need a robust caching of the listeners because
otherwise you will need to visit all components and behaviors again
and again.


On Tue, Jun 19, 2012 at 10:58 PM, Jeremy Thomerson
<je...@wickettraining.com> wrote:
> Have we talked about adding an IEventDispatcher that dispatches events by
> their class type based on event method signature?
>
> Example:
>
> class MyComponent {
>
> @EventListener // or some annotation
> public void onUserAddedEvent(UserAddedEvent event) {
>  // do something here
> }
>
> }
>
> Then when someone calls sink(new UserAddedEvent()) it gets dispatched to
> only those methods that take a UserAddedEvent as their method argument?
>
> Would that be useful (it seems like it to me - it avoids the instanceof
> checks)?  Am I off track?  Is there something like this or better already
> built?
>
> An alternative would be that the annotation could take an argument of event
> class(es) that it want's to be notified of.
>
>
>
>
> --
> Jeremy Thomerson
> http://wickettraining.com
> *Need a CMS for Wicket?  Use Brix! http://brixcms.org*
>
>
>
> On Tue, Jun 19, 2012 at 2:36 PM, Igor Vaynberg <ig...@gmail.com>wrote:
>
>>
>> http://grepcode.com/file/repo1.maven.org/maven2/org.apache.wicket/wicket-core/6.0.0-beta1/org/apache/wicket/EventDispatcherTest.java#EventDispatcherTest
>>
>> -igor
>>
>> On Tue, Jun 19, 2012 at 12:31 PM, Douglas Ferguson <th...@gmail.com>
>> wrote:
>> > Where's the source repository located?
>> >
>> >
>> > On Jun 19, 2012, at 2:20 PM, Martin Grigorov wrote:
>> >
>> >> See org.apache.wicket.EventDispatcherTest in wicket-core's tests
>> >>
>> >> On Tue, Jun 19, 2012 at 9:58 PM, Douglas Ferguson <th...@gmail.com>
>> wrote:
>> >>> Anybody have a good pattern for using Events without having lots of
>> instanceOf, if/else, or switch statements?
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> For additional commands, e-mail: users-help@wicket.apache.org
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> Martin Grigorov
>> >> jWeekend
>> >> Training, Consulting, Development
>> >> http://jWeekend.com
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket Events

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Have we talked about adding an IEventDispatcher that dispatches events by
their class type based on event method signature?

Example:

class MyComponent {

@EventListener // or some annotation
public void onUserAddedEvent(UserAddedEvent event) {
  // do something here
}

}

Then when someone calls sink(new UserAddedEvent()) it gets dispatched to
only those methods that take a UserAddedEvent as their method argument?

Would that be useful (it seems like it to me - it avoids the instanceof
checks)?  Am I off track?  Is there something like this or better already
built?

An alternative would be that the annotation could take an argument of event
class(es) that it want's to be notified of.




-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*



On Tue, Jun 19, 2012 at 2:36 PM, Igor Vaynberg <ig...@gmail.com>wrote:

>
> http://grepcode.com/file/repo1.maven.org/maven2/org.apache.wicket/wicket-core/6.0.0-beta1/org/apache/wicket/EventDispatcherTest.java#EventDispatcherTest
>
> -igor
>
> On Tue, Jun 19, 2012 at 12:31 PM, Douglas Ferguson <th...@gmail.com>
> wrote:
> > Where's the source repository located?
> >
> >
> > On Jun 19, 2012, at 2:20 PM, Martin Grigorov wrote:
> >
> >> See org.apache.wicket.EventDispatcherTest in wicket-core's tests
> >>
> >> On Tue, Jun 19, 2012 at 9:58 PM, Douglas Ferguson <th...@gmail.com>
> wrote:
> >>> Anybody have a good pattern for using Events without having lots of
> instanceOf, if/else, or switch statements?
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>
> >>
> >>
> >>
> >> --
> >> Martin Grigorov
> >> jWeekend
> >> Training, Consulting, Development
> >> http://jWeekend.com
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Wicket Events

Posted by Igor Vaynberg <ig...@gmail.com>.
http://grepcode.com/file/repo1.maven.org/maven2/org.apache.wicket/wicket-core/6.0.0-beta1/org/apache/wicket/EventDispatcherTest.java#EventDispatcherTest

-igor

On Tue, Jun 19, 2012 at 12:31 PM, Douglas Ferguson <th...@gmail.com> wrote:
> Where's the source repository located?
>
>
> On Jun 19, 2012, at 2:20 PM, Martin Grigorov wrote:
>
>> See org.apache.wicket.EventDispatcherTest in wicket-core's tests
>>
>> On Tue, Jun 19, 2012 at 9:58 PM, Douglas Ferguson <th...@gmail.com> wrote:
>>> Anybody have a good pattern for using Events without having lots of instanceOf, if/else, or switch statements?
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>
>>
>>
>> --
>> Martin Grigorov
>> jWeekend
>> Training, Consulting, Development
>> http://jWeekend.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket Events

Posted by Douglas Ferguson <th...@gmail.com>.
Where's the source repository located?


On Jun 19, 2012, at 2:20 PM, Martin Grigorov wrote:

> See org.apache.wicket.EventDispatcherTest in wicket-core's tests
> 
> On Tue, Jun 19, 2012 at 9:58 PM, Douglas Ferguson <th...@gmail.com> wrote:
>> Anybody have a good pattern for using Events without having lots of instanceOf, if/else, or switch statements?
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
> 
> 
> 
> -- 
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket Events

Posted by Douglas Ferguson <th...@gmail.com>.
I was able to get the EventDispatcher to work. 

I added an annotation and as well as an Enum with my EventTypes.

It works quite nicely.

Thanks for the tips.

Douglas

On Jun 19, 2012, at 7:15 PM, Douglas Ferguson wrote:

> Yeah.. when I read Jeremy's reply it was the kind of thing I was looking for but my understanding was that 
> Jeremy was suggesting it as a possible approach. Are you saying this will work out of the box?
> 
> 
> On Jun 19, 2012, at 3:40 PM, Martin Grigorov wrote:
> 
>> As the tests shows this is pluggable in Wicket.
>> There is a default impl that uses casting of the payload and there is
>> a way to setup your own impl that does it your way.
>> See Jeremy's message in this thread for a solution that works as Google's one.
>> 
>> On Tue, Jun 19, 2012 at 11:36 PM, Douglas Ferguson <th...@gmail.com> wrote:
>>> Yeah... i just don't like the idea of unpacking the payload and doing instanceOf, if/else do decide if I care about that message.
>>> 
>>> The GoogleEvent buss approach seems better. I.E. Implement the specific methods for the specific event types.
>>> 
>>> Douglas
>>> 
>>> On Jun 19, 2012, at 3:20 PM, Martin Grigorov wrote:
>>> 
>>>> Wicket always sends ComponentEvent.
>>>> The dynamic part is the event's payload.
>>>> The test shows how to receive the payload in a type-safe way.
>>>> 
>>>> On Tue, Jun 19, 2012 at 11:16 PM, Douglas Ferguson <th...@gmail.com> wrote:
>>>>> Ok.. So I took a look at it and it is ignoring the IEvent.
>>>>> 
>>>>> I'm actually interested in how to cleanly handle multiple type of IEvents without having to
>>>>> do if/else or instanceOf. Was curious if anybody had a nice pattern to follow.
>>>>> 
>>>>>       @Override
>>>>> 115             public void onEvent(Component component, IEvent<?> event)
>>>>> 116             {
>>>>> 117                     invocationTimes++;
>>>>> 118             }
>>>>> 119
>>>>> 
>>>>> 
>>>>> 
>>>>> On Jun 19, 2012, at 2:20 PM, Martin Grigorov wrote:
>>>>> 
>>>>>> See org.apache.wicket.EventDispatcherTest in wicket-core's tests
>>>>>> 
>>>>>> On Tue, Jun 19, 2012 at 9:58 PM, Douglas Ferguson <th...@gmail.com> wrote:
>>>>>>> Anybody have a good pattern for using Events without having lots of instanceOf, if/else, or switch statements?
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> --
>>>>>> Martin Grigorov
>>>>>> jWeekend
>>>>>> Training, Consulting, Development
>>>>>> http://jWeekend.com
>>>>>> 
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>> 
>>>>> 
>>>>> 
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>> 
>>>> 
>>>> 
>>>> 
>>>> --
>>>> Martin Grigorov
>>>> jWeekend
>>>> Training, Consulting, Development
>>>> http://jWeekend.com
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>> 
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>> 
>> 
>> 
>> 
>> -- 
>> Martin Grigorov
>> jWeekend
>> Training, Consulting, Development
>> http://jWeekend.com
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket Events

Posted by Douglas Ferguson <th...@gmail.com>.
Yeah.. when I read Jeremy's reply it was the kind of thing I was looking for but my understanding was that 
Jeremy was suggesting it as a possible approach. Are you saying this will work out of the box?


On Jun 19, 2012, at 3:40 PM, Martin Grigorov wrote:

> As the tests shows this is pluggable in Wicket.
> There is a default impl that uses casting of the payload and there is
> a way to setup your own impl that does it your way.
> See Jeremy's message in this thread for a solution that works as Google's one.
> 
> On Tue, Jun 19, 2012 at 11:36 PM, Douglas Ferguson <th...@gmail.com> wrote:
>> Yeah... i just don't like the idea of unpacking the payload and doing instanceOf, if/else do decide if I care about that message.
>> 
>> The GoogleEvent buss approach seems better. I.E. Implement the specific methods for the specific event types.
>> 
>> Douglas
>> 
>> On Jun 19, 2012, at 3:20 PM, Martin Grigorov wrote:
>> 
>>> Wicket always sends ComponentEvent.
>>> The dynamic part is the event's payload.
>>> The test shows how to receive the payload in a type-safe way.
>>> 
>>> On Tue, Jun 19, 2012 at 11:16 PM, Douglas Ferguson <th...@gmail.com> wrote:
>>>> Ok.. So I took a look at it and it is ignoring the IEvent.
>>>> 
>>>> I'm actually interested in how to cleanly handle multiple type of IEvents without having to
>>>> do if/else or instanceOf. Was curious if anybody had a nice pattern to follow.
>>>> 
>>>>        @Override
>>>> 115             public void onEvent(Component component, IEvent<?> event)
>>>> 116             {
>>>> 117                     invocationTimes++;
>>>> 118             }
>>>> 119
>>>> 
>>>> 
>>>> 
>>>> On Jun 19, 2012, at 2:20 PM, Martin Grigorov wrote:
>>>> 
>>>>> See org.apache.wicket.EventDispatcherTest in wicket-core's tests
>>>>> 
>>>>> On Tue, Jun 19, 2012 at 9:58 PM, Douglas Ferguson <th...@gmail.com> wrote:
>>>>>> Anybody have a good pattern for using Events without having lots of instanceOf, if/else, or switch statements?
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> --
>>>>> Martin Grigorov
>>>>> jWeekend
>>>>> Training, Consulting, Development
>>>>> http://jWeekend.com
>>>>> 
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>> 
>>>> 
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>> 
>>> 
>>> 
>>> 
>>> --
>>> Martin Grigorov
>>> jWeekend
>>> Training, Consulting, Development
>>> http://jWeekend.com
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
> 
> 
> 
> -- 
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket Events

Posted by Martin Grigorov <mg...@apache.org>.
As the tests shows this is pluggable in Wicket.
There is a default impl that uses casting of the payload and there is
a way to setup your own impl that does it your way.
See Jeremy's message in this thread for a solution that works as Google's one.

On Tue, Jun 19, 2012 at 11:36 PM, Douglas Ferguson <th...@gmail.com> wrote:
> Yeah... i just don't like the idea of unpacking the payload and doing instanceOf, if/else do decide if I care about that message.
>
> The GoogleEvent buss approach seems better. I.E. Implement the specific methods for the specific event types.
>
> Douglas
>
> On Jun 19, 2012, at 3:20 PM, Martin Grigorov wrote:
>
>> Wicket always sends ComponentEvent.
>> The dynamic part is the event's payload.
>> The test shows how to receive the payload in a type-safe way.
>>
>> On Tue, Jun 19, 2012 at 11:16 PM, Douglas Ferguson <th...@gmail.com> wrote:
>>> Ok.. So I took a look at it and it is ignoring the IEvent.
>>>
>>> I'm actually interested in how to cleanly handle multiple type of IEvents without having to
>>> do if/else or instanceOf. Was curious if anybody had a nice pattern to follow.
>>>
>>>        @Override
>>> 115             public void onEvent(Component component, IEvent<?> event)
>>> 116             {
>>> 117                     invocationTimes++;
>>> 118             }
>>> 119
>>>
>>>
>>>
>>> On Jun 19, 2012, at 2:20 PM, Martin Grigorov wrote:
>>>
>>>> See org.apache.wicket.EventDispatcherTest in wicket-core's tests
>>>>
>>>> On Tue, Jun 19, 2012 at 9:58 PM, Douglas Ferguson <th...@gmail.com> wrote:
>>>>> Anybody have a good pattern for using Events without having lots of instanceOf, if/else, or switch statements?
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Martin Grigorov
>>>> jWeekend
>>>> Training, Consulting, Development
>>>> http://jWeekend.com
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>
>>
>>
>> --
>> Martin Grigorov
>> jWeekend
>> Training, Consulting, Development
>> http://jWeekend.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket Events

Posted by Douglas Ferguson <th...@gmail.com>.
Yeah... i just don't like the idea of unpacking the payload and doing instanceOf, if/else do decide if I care about that message.

The GoogleEvent buss approach seems better. I.E. Implement the specific methods for the specific event types.

Douglas

On Jun 19, 2012, at 3:20 PM, Martin Grigorov wrote:

> Wicket always sends ComponentEvent.
> The dynamic part is the event's payload.
> The test shows how to receive the payload in a type-safe way.
> 
> On Tue, Jun 19, 2012 at 11:16 PM, Douglas Ferguson <th...@gmail.com> wrote:
>> Ok.. So I took a look at it and it is ignoring the IEvent.
>> 
>> I'm actually interested in how to cleanly handle multiple type of IEvents without having to
>> do if/else or instanceOf. Was curious if anybody had a nice pattern to follow.
>> 
>>        @Override
>> 115             public void onEvent(Component component, IEvent<?> event)
>> 116             {
>> 117                     invocationTimes++;
>> 118             }
>> 119
>> 
>> 
>> 
>> On Jun 19, 2012, at 2:20 PM, Martin Grigorov wrote:
>> 
>>> See org.apache.wicket.EventDispatcherTest in wicket-core's tests
>>> 
>>> On Tue, Jun 19, 2012 at 9:58 PM, Douglas Ferguson <th...@gmail.com> wrote:
>>>> Anybody have a good pattern for using Events without having lots of instanceOf, if/else, or switch statements?
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>> 
>>> 
>>> 
>>> 
>>> --
>>> Martin Grigorov
>>> jWeekend
>>> Training, Consulting, Development
>>> http://jWeekend.com
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
> 
> 
> 
> -- 
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket Events

Posted by Martin Grigorov <mg...@apache.org>.
Wicket always sends ComponentEvent.
The dynamic part is the event's payload.
The test shows how to receive the payload in a type-safe way.

On Tue, Jun 19, 2012 at 11:16 PM, Douglas Ferguson <th...@gmail.com> wrote:
> Ok.. So I took a look at it and it is ignoring the IEvent.
>
> I'm actually interested in how to cleanly handle multiple type of IEvents without having to
> do if/else or instanceOf. Was curious if anybody had a nice pattern to follow.
>
>        @Override
> 115             public void onEvent(Component component, IEvent<?> event)
> 116             {
> 117                     invocationTimes++;
> 118             }
> 119
>
>
>
> On Jun 19, 2012, at 2:20 PM, Martin Grigorov wrote:
>
>> See org.apache.wicket.EventDispatcherTest in wicket-core's tests
>>
>> On Tue, Jun 19, 2012 at 9:58 PM, Douglas Ferguson <th...@gmail.com> wrote:
>>> Anybody have a good pattern for using Events without having lots of instanceOf, if/else, or switch statements?
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>
>>
>>
>> --
>> Martin Grigorov
>> jWeekend
>> Training, Consulting, Development
>> http://jWeekend.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket Events

Posted by Douglas Ferguson <th...@gmail.com>.
Ok.. So I took a look at it and it is ignoring the IEvent.

I'm actually interested in how to cleanly handle multiple type of IEvents without having to 
do if/else or instanceOf. Was curious if anybody had a nice pattern to follow.

	@Override
115		public void onEvent(Component component, IEvent<?> event)
116		{
117			invocationTimes++;
118		}
119



On Jun 19, 2012, at 2:20 PM, Martin Grigorov wrote:

> See org.apache.wicket.EventDispatcherTest in wicket-core's tests
> 
> On Tue, Jun 19, 2012 at 9:58 PM, Douglas Ferguson <th...@gmail.com> wrote:
>> Anybody have a good pattern for using Events without having lots of instanceOf, if/else, or switch statements?
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
> 
> 
> 
> -- 
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket Events

Posted by Martin Grigorov <mg...@apache.org>.
See org.apache.wicket.EventDispatcherTest in wicket-core's tests

On Tue, Jun 19, 2012 at 9:58 PM, Douglas Ferguson <th...@gmail.com> wrote:
> Anybody have a good pattern for using Events without having lots of instanceOf, if/else, or switch statements?
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org