Passing parameters to a viewlet

Dear all,

I'm writing a viewlet and I want to pass a parameter to it. Which is
the best practice for that?

I have wirtten a .cfm as the viewlet which is called by the layout
with renderView().

This .cfm calls an event with runEvent(). The event handler then uses
the model to calculate the result.

However in this approach, how could I send a parameter to the viewlet
(.cfm) called with renderView()? And then how could I send the
parameter to the viewlet manager called with runEvent()?

Of course I could use the event/request collection, but does not seem
like a clean solution to me.

Any ideas/advice?

Thanks for your kind help.

You really did hit on it with the RC. We have, in our huge system,
probably more viewlets than straight views. A single view for us
would typically call one or more viewlets, by function:

View A:
   - runEvent('myHandler.viewletFunction1')
   - runEvent('myHandler.viewletFunction2')

Those functions 1 & 2 in the handler would setup any needed RC
variables of their own, then do a <cfset renderView('area/viewlets/
viewlet1') /> type call.

If it makes you feel better to "encapsulate" more (since you really
can't do parameters), you could do something like generate a UUID key,
place it at the top each view (being unique each time), then use that
key to store rc variables. Like so: <cfset rc['the-big-uuid-
here'].myVar = 1 /> Kinda unwieldy but would at least allow you to

A lot of our stuff runs around real estate property, so we might have
rc.qProperty defined in the primary handler event, but continue to
reference it in the viewlets. We don't want to fetch it again,
obviously, but so many of our views rely on it that you could consider
it "un-encapsulated". Remember, the RC is a shared scope and lives
for the life of the request. Use it...let it make your life easier.

- Will B.