Event Class (was Re: [Arp] Central dispatcher)
Christophe Herreman
lists at herrodius.com
Wed Apr 20 10:33:03 PDT 2005
Hi Darron,
> This is what's done in C#. So, instead of new Event("SavePerson") I would
> have new SavePersonEvent(target, the_person_data_to_save).
What would be the event-type of SavePersonEvent? Just "savePerson" or
"onSavePerson" or something like that. I like the idea of having custom
event classes in an application but I'm just thinking that it could make it
a little harder to know what type/name to use in the class that handles the
event.
Say I have this Event class:
<code>
class com.ariaware.arp.event.Event{
public var type:String;
public function Event(type:String){
this.type = type;
}
public function toString():String{
return "[com.ariaware.arp.event.Event - Type: " + type + "]";
}
}
</code>
And then I have an event that extends it:
<code>
import com.ariaware.arp.event.Event;
import be.idiomatic.model.Assessment;
class be.idiomatic.event.StartAssessmentEvent extends Event{
private var assessment:Assessment;
public function StartAssessmentEvent(assessment:Assessment){
super("onStartAssessment");
this.assessment = assessment;
}
public function getAssessment():Assessment{
return assessment;
}
public function toString():String{
var result:String = "[be.idiomatic.event.StartAssessmentEvent\n";
result += "- Type: " + type + "\n";
result += "- Assessment: " + assessment + "\n";
result += "]";
return result;
}
}
</code>
When I dispatch a StartAssessmentEvent, I have to know that the type of the
event is "onStartAssessment". Is this how it should work, or am I missing
something here?
regards,
Christophe
----- Original Message -----
From: "Darron J. Schall" <darron at darronschall.com>
To: "General List for Ariaware RIA Platform users and developers"
<Arp at ariaware.com>
Sent: Wednesday, April 20, 2005 5:27 PM
Subject: Re: [Arp] Central dispatcher
> Aral Balkan wrote:
>
>> Thinking about it... if the Controller, instead of passing a viewRef,
>> just passed the Command a reference to the event object, it would
>> probably make the system more flexible. Is this what you're doing Darron?
>
>
> Yes, sorry.. I haven't been following this thread closely (it's long and I
> missed the beginning of it, and I have to get something done before 2
> today). The controller passes the entire event to the command, and lets
> the command figure out what to do with it. This way, I get the view that
> generated the event (event.target), and I also get all of the necessary
> data that the command needs (event.data).. for instance, I would pass a VO
> as event.data, because the "SavePerson" event *needs* the VO, because the
> VO describes what needs to be saved.
>
>> This still wouldn't make events independent, though...
>
>
> Why not? It would probably be better, instead of just using one main
> Event and stuffing different things into event.data, to create subclasses
> of events. This is what's done in C#. So, instead of new
> Event("SavePerson") I would have new SavePersonEvent(target,
> the_person_data_to_save).
>
> I might be confused just from not paying attention to the tread though.
> If this doesn't make sense, just ignore me.. kinda swamped today.
>
> -d
>
>
>
> _______________________________________________
> Arp mailing list
> Arp at ariaware.com
> http://ariaware.com/mailman/listinfo/arp_ariaware.com
>
More information about the Arp
mailing list