[coldbox:25117] [ColdBox 3.8]Cannot pass rc to an extended handler

Hi Kaymaz,

function param list does not match
super.renderPage(Event = Event, rc = rc, prc = prc); return;

---------renderPage(any Event, array pageName = [], any rc = {}, any prc = {})

super.renderPage(pageNames = ['profile'], Event = arguments.Event, rc = arguments.rc, prc = arguments.prc);

`
public void function renderPage(array pageNames = [], any Event = {}, any rc = {}, any prc = {}) {

Event.setView(‘usermessage’);

for (pageName in arguments.pageNames) {
Event.setView(pageName);
}
}
`

The userMessage view does display anything but the ‘pageName’ view display can access well rc, prc, Event and render thing.

Handlers really should not be extending each other, if they share common code then that code really should in a model or a base class that they both can extent. But I consider it dangerous to extend other handlers like this.

Now Event.setView in a loop like that, I am not sure that will work the way you intend it to work either.

Handlers really should not be extending each other, if they share common code then that code really should in a model or a base class that they both can extent.

That is basically what I do, They are not used as handlers, just a ‘model handler’.

Now Event.setView in a loop like that, I am not sure that will work the way you intend it to work either.

How can I do that? Do you mean it’s only possible to call once event.setView()?

They are still handlers, if I here what you’re saying. A base class is not a handler. SO it might be the way you have worded it then.

I believe so yes, I would perhaps look at renderView() instead if you want to concatenate them. If I recall right, don’t quote me on this as it has been a long time. But setView sets the view to be rendered so the render knows how to render them, when the handler finishes.

Only the last event.setView() will do anything. All that method does is jot down the name of the view to be rendered later in the request lifecycle.

if you want to render a bunch of views at once, you want to use the renderView() method. You’ll need to capture the HTML that each view returns and do something with it. Whatever you’re doing might be better off put in a view or a layout instead of the handler.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com