I have a viewlet which is some simple search HTML… some of the drop downs in this search box are populated by data.
So I have created a method in my event which populates the data into the event scope … the view page can then consume this data from the event.
This search HTML will be used in various places throughout my application.
I have attempted doing it using persistStruct and the event structure but with no luck
//Product List data set into event scope
//set the view to be shown within the product list layout
//set the next event persisting all event arguments
Not sure why your using a runevent then a setview in your handler, personally I would use a model or service instead.
But your question can be answered with http://wiki.coldbox.org/wiki/FlashRam/wiki/FlashRAM.cfm
I assume you mean setProductSearchData into a service.
That would be useful since it would be easily accessible by other handlers…
however I had thought that my model should be completely platform independent so although my setProductSearchData calls a service to get the data
when it comes to putting that data into the event scope I use a Handler.
Thanks for link… will have a read through.
You know all events unless you make them private can be run from the URL? I am also positive that around handlers and other interceptor points can be applied to them as well. Which means you could end up making your code slower than it needs to be.
From the docs.
Executing other events (Event Chaining)
The best practice on event execution would be via the runEvent() method. However, please note that running events via this method does a complete life cycle execution. So do not abuse it. If you find that you need to chain events or are getting more complex, we suggest upgrading your code to use ColdBox Interceptors. This is a much more flexible and decoupled way of providing executing code chains.
Thanks… yes I think Interceptors would be a much better solution.