runevent arguments

I’m working on a widget for coldbox and I haven’t used runevent before. In my widget I do a savecontent and return the string. The savecontent is a writeoutput of a runevent into which I am passing arguments from the widget. The runevent basically does a renderview on a viewlet. The problem is I can’t see find the arguments in the viewlet that should be there from the runevent. Right now the viewlet is nothing more than a few dumps. Can anyone help me connect the dots here?

my renderit function in the widget copied from the viewlet widget in contentbox and slightly modified.

any function renderIt(required string eventid){

var rString = “”;
var eventArguments = {};

if( len( arguments.eventid ) ){

var aString = listToArray( arguments.eventid, “,” );
for( var key in aString ){
eventArguments[ listFirst( key, “=” ) ] = getToken( key, 2, “=” );
}
}
saveContent variable=“rString”{

try{
writeOutput( runEvent(event=“widgets.whoiscoming”,eventArguments=eventArguments) );
}
catch(Any e){
writeOutput(“Error executing viewlet #arguments.event#(#arguments.args.toString()#). #e.message#”);
log.error(“Error executing viewlet: #arguments.event#(#arguments.args.toString()#)”,e);
}
}
return rString;

}

my simple handler

component{
function whoiscoming(event,rc,prc,eventArguments)

{
return renderView("/views/whoiscoming");

}
}

You are almost there.

The only thing that I can’t decipher is your arguments what your exactly doing, but it looks like you are not defining an key, value relationship which the passing of arguments requires.

You don’t specify what the error is you’re getting, but I am guessing it would have told you what the problem is.

Also you don’t need to do this in a handler.

component{
function whoiscoming(event,rc,prc,eventArguments)

{
return renderView("/views/whoiscoming");

}
}

It should be

component {
function whoiscoming(event, rc, prc,eventArguments) {
event.renderView("/views/whoiscoming");

}
}

I should’ve thought to include that. Sorry. I’m getting.

Error translating widget: Element EVENT is undefined in ARGUMENTS.

Thanks. I have the renderview part working but I was planning to use a runevent so I could inject a model and get the data I needed for the viewlet.

Sorry I wasn’t getting any error until I tired to change my handler to

function whoiscoming(event,rc,prc,eventArguments)
{
return renderView(view="/views/whoiscoming",args=arguments.eventArguments);
}

Problem is I can just stop the handler dump stuff out because I get the event error.

event is undefined in arguments, which line is throwing that error?

It’s in the renderview in the handler.

function whoiscoming(event,rc,prc,eventArguments)
{
return renderView(view="/views/whoiscoming",args=eventArguments.);
}

Ok here is your problem

try{
writeOutput( runEvent(event=“widgets.whoiscoming”,eventArguments=eventArguments) );
}
catch(Any e){
writeOutput(“Error executing viewlet #arguments.event#(#arguments.args.toString()#). #e.message#”);
log.error(“Error executing viewlet: #arguments.event#(#arguments.args.toString()#)”,e);
}

Notice your catch is using arguments.event, but your not passing even into the renderer. The error message would have been very clear about this.

Thank you. Now I’m getting the real error. Just changed the writeoutput to what catch had.

Element EVENTARGUMENTS is undefined in ARGUMENTS.

The problem was the catch statement I had pasted all along keeping from doing simple dumps.

Thanks for the fresh eyes.

No problem, sometimes when you stare at something long enough, you become oblivious to it.

But it goes to show that even I missed it the first time :frowning: