You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Pranav kacholia <pr...@gmail.com> on 2011/09/27 19:06:31 UTC
AbstractComponentEventSender
I was going through the wicket code and i think a lot of the code that is
available in ComponentEventSender should be made reuseable. Right now it is
final, which makes sense since i cant see any real extension points in it.
Perhaps the following change:- (alongside making ComponentEvent non-final)
(the following probably wont compile, but you get the idea)
final class ComponentEvent<T> extends AbstractComponentEventSender{
/////
@Override
public ComponentEvent<T> generateEvent(IEventSink sink, Broadcast type, T
payload) {
return new ComponentEvent<T>(sink, source, type, payload);
}
}
public abstract class AbstractComponentEventSender<T> implements
IEventSource{
// all code remains the same as existing ComponentEventSender
public <T> void send(IEventSink sink, Broadcast type, T payload)
{
ComponentEvent<?>event =generateEvent();
// ComponentEvent<?> event = new ComponentEvent<T>(sink, source, type,
payload);
Args.notNull(type, "type");
switch (type)
{
case BUBBLE :
bubble(event);
break;
case BREADTH :
breadth(event);
break;
case DEPTH :
depth(event);
break;
case EXACT :
dispatcher.dispatchEvent(event.getSink(), event, ((sink instanceof
Component)
? (Component)sink : null));
break;
}
}
abstract public ComponentEvent generateEvent(IEventSink sink, Broadcast
type, T payload) ;
}
///****************************************
Doing this would enable everyone to extend AbstractComponentEventSender to
use new Events which would be extensions of ComponentEvent.
I would have preferred to use IEvent, but the interface only has 'set'
methods for all its variables, and no "get' methods, so we cant really use
that.
Ithink it would increase the flexibility and prevent people from having to
copy-paste componenteventsender which is more complicated to rebuild from
scratch than writing a new IEventDispatcher..
In Wicket.next i think the "get" methods should be included int the IEvent
interface.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AbstractComponentEventSender-tp3848238p3848238.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: AbstractComponentEventSender
Posted by Pranav kacholia <pr...@gmail.com>.
Alright. Thank you :)
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AbstractComponentEventSender-tp3848238p3849133.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: AbstractComponentEventSender
Posted by Igor Vaynberg <ig...@gmail.com>.
you are not meant to provide your own implementations of IEvent,
rather it is IEvent#getPayload() that contain different
representations of the event.
-igor
On Tue, Sep 27, 2011 at 12:16 PM, Pranav kacholia
<pr...@gmail.com> wrote:
> It is more about the ability to choose which class of event you are
> despatching. In this case they will be all extending ComponentEvent. Maybe
> there is someway of having a generic IEvent child class sent.
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/AbstractComponentEventSender-tp3848238p3848687.html
> Sent from the Users forum mailing list archive at Nabble.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: AbstractComponentEventSender
Posted by Pranav kacholia <pr...@gmail.com>.
It is more about the ability to choose which class of event you are
despatching. In this case they will be all extending ComponentEvent. Maybe
there is someway of having a generic IEvent child class sent.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AbstractComponentEventSender-tp3848238p3848687.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: AbstractComponentEventSender
Posted by Martin Grigorov <mg...@apache.org>.
What other specializations of AbstractComponentEventSender do you need ?
On Tue, Sep 27, 2011 at 7:06 PM, Pranav kacholia
<pr...@gmail.com> wrote:
> I was going through the wicket code and i think a lot of the code that is
> available in ComponentEventSender should be made reuseable. Right now it is
> final, which makes sense since i cant see any real extension points in it.
>
> Perhaps the following change:- (alongside making ComponentEvent non-final)
> (the following probably wont compile, but you get the idea)
>
> final class ComponentEvent<T> extends AbstractComponentEventSender{
> /////
>
> @Override
> public ComponentEvent<T> generateEvent(IEventSink sink, Broadcast type, T
> payload) {
> return new ComponentEvent<T>(sink, source, type, payload);
> }
> }
>
> public abstract class AbstractComponentEventSender<T> implements
> IEventSource{
> // all code remains the same as existing ComponentEventSender
>
> public <T> void send(IEventSink sink, Broadcast type, T payload)
> {
> ComponentEvent<?>event =generateEvent();
> // ComponentEvent<?> event = new ComponentEvent<T>(sink, source, type,
> payload);
> Args.notNull(type, "type");
> switch (type)
> {
> case BUBBLE :
> bubble(event);
> break;
> case BREADTH :
> breadth(event);
> break;
> case DEPTH :
> depth(event);
> break;
> case EXACT :
> dispatcher.dispatchEvent(event.getSink(), event, ((sink instanceof
> Component)
> ? (Component)sink : null));
> break;
> }
> }
>
> abstract public ComponentEvent generateEvent(IEventSink sink, Broadcast
> type, T payload) ;
>
> }
>
>
> ///****************************************
>
> Doing this would enable everyone to extend AbstractComponentEventSender to
> use new Events which would be extensions of ComponentEvent.
>
> I would have preferred to use IEvent, but the interface only has 'set'
> methods for all its variables, and no "get' methods, so we cant really use
> that.
>
> Ithink it would increase the flexibility and prevent people from having to
> copy-paste componenteventsender which is more complicated to rebuild from
> scratch than writing a new IEventDispatcher..
>
> In Wicket.next i think the "get" methods should be included int the IEvent
> interface.
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/AbstractComponentEventSender-tp3848238p3848238.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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