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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to