Hello Guys,
I’ve configured onInvalidEvent and it’s work just great! (that was very easy)
Now, what I want to do is trigger onInvalidEvent behaviour from other events, in a similar manor to setNextEvent.
For instance, let’s say a user looks at an event like this /index.cfm?event=someValidEvent&some_id=InvalidID
I want to recognise that the ID isn’t a valid one, using some logic in my handler, and then throw the invalid event.
I’m currently doing it like this, using runEvent() which works great!
public void function view(any event) {
// TODO: We need to find some method for securing this, to stop users from viewing one anothers services.
// One way suggested to do this is to pull the view by ID scoped to the account, this would be easy in rails, cf, not so much.
// Grab the event collection from the event.
local.rc = event.getCollection();
// Collect the servie entity for diplay.
local.rc.service = serviceService.get(local.rc.service_id);
// Check to ensure that this service exists.
if (isNull(local.rc.service)) {
// A service was not found matching that ID.
// Route them to the page not found event.
runEvent(‘main.pageNotFound’);
}
}
My only concern with this is that if I change my 404 event handler to something else, then I have to go through the application changing these references.
Is there a better way of doing this? or could there be? What about some form of facade method like invalid() which triggers this behaviour? Any suggestions?
Thanks,
Robert