Can someone try this in the latest Coldbox build and ColdFusion 9

I am trying to override the Render.cfc which works in normal cfscript, however when I wrote it like this

//-----------------------------------------------------------------------

//-----------------------------------------------------------------------

component extends=“coldbox.system.Plugins.Renderer” output=“false” {

public function renderView(string view, boolean cache, string cacheTimeout, string cacheLastAccessTimeout) {

return super.renderView(arguments.view, arguments.cache, arguments.cacheTimeout, arguments.cacheLastAccessTimeout);

}

}

It throws an error saying arguments.view is not defined, when I debugged this I found that the arguments are not being passed into this function at all.

Anyone else able to see this same problem?

Those are all optional arguments and, since you can call renderView()
like that, no arguments would be passed.

This is a case where you have to use argumentCollection:

return super.view( argumentCollection = arguments );

Sean,

Yeah I am aware of that, but this is using the extension/plugin to override
the core render.cfc so I don't have control of that part.

Are you saying I need to check the length of the argumentCollection and then
call renderView() without arguments if there is none?

Regards,
Andrew Scott

No, I'm just saying that all the arguments are optional so you simply
cannot dereference them as arguments.x - you *must* use
argumentCollection= in your super.renderView() call. This has nothing
to do with ColdBox, it's just basic CFML handling of optional
arguments.

Sean,

Yeah, But I did say I am using the extension/plugin/render.cfc to override
the normal Render.cfc and that means I don't have control over this and that
is ColdBox.

In other words ColdBox is calling this not me.

Regards,
Andrew Scott

Of Sean Corfield

You're missing the point: the arguments are optional - they will not
all be present. In the super method, they have defaults which the code
relies on.

Your choices are either:
* argumentCollection - per my suggestion
* add defaults to your function that match ColdBox's renderView -
brittle... if ever the CB defaults change you might get subtle errors

Here's your function with defaults to match CB:

public function renderView(string view = '', boolean cache = false,
string cacheTimeout = '', string cacheLastAccessTimeout = '' )

Sean,

Damn, you are right I missed the defaults. That's what you get for being 4am
here.

Cheers.

Regards,
Andrew Scott

Of Sean Corfield

NP. It's 11am Saturday morning here in sunny California and I'm barely
awake yet :slight_smile: