Content output not working when reload = false

17 views
Skip to first unread message

Joe Bernard

unread,
Apr 23, 2012, 5:06:29 PM4/23/12
to model-glue
I'm working with a bit of an unorthodox setup trying to generate some
content, and have a problem when MG reload = false.

I have a bean in coldspring with a method that directly outputs HTML.
It is from a library and I can't change it. In my controller I am
calling beans.myBean.render() invokes this function. I have this call
wrapped in saveContent, which I use to pass the rendered HTML out to
my view. My controller calls the bean, captures the output to a
variable, and sets it in the event for the view to display. So far so
good, this all works.... until I set reload = false in ColdSpring.xml.

When reload = false, the content being output in the render function
is suppressed. My saveContent captures an empty string and the content
is not displayed.

I've tried wrapping the content in writeOutput() thinking maybe MG was
calling cfsetting's enableCFOutputOnly=true property somewhere, but
that didn't fix the issue.

I'm running MG 3.2.439.

Any ideas?

Chris Blackwell

unread,
Apr 25, 2012, 3:52:52 AM4/25/12
to model...@googlegroups.com
Hi Joe,

It sounds to me like the problem lies within your bean, but without knowing a bit more about what its doing when you call render() its impossible to guess.

Can you provide some more info, or maybe some code?

Cheers, Chris

--
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog

You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to model...@googlegroups.com
To unsubscribe from this group, send email to
model-glue+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

Joe Bernard

unread,
Apr 26, 2012, 12:29:30 PM4/26/12
to model...@googlegroups.com
Chris,

Here's the code, I've stripped out some irrelevant bits.

In the the controller I call UIRender(), and set the results in the event.
Controller: Security.cfc

public void function generateUI(event){

local.renderedResult = UIRender();

arguments.event.setValue("RenderResults", local.renderedResult);

}

private string function UIRender(){

return beans.UIService.getUIRender();

}

In this service, I call the render function on the library. It outputs HTML directly within the function, so I capture that using saveContent, and return it.

Service: UIService.cfc

public string function getUIRender(){

saveContent variable="local.renderedContent"{

// this.getUI() returns the library that renders the HTML. The library is injected into UIService via ColdSpring.

writeOutput(this.getUI().render());

};

return local.renderedContent;

}

Here is the library function that just outputs HTML. I can't change this function.
Library component: UI.cfc

<cffunction name="render" output="yes">

Please sign in with your username, email address, or client number.

<div class="ui_diag" id="SignIn">

<form method="post" action="#createGetVariables(FormAction)#">

<legend>Sign In</legend>

<input name="username" type="text" id="username" value=""></input>

<input name="password" type="password" id="clear_pw" value=""></input>

<button type="submit" name="action" value="submit-signin"">Sign In</button>

</cffunction>

And here is the view that outputs the rendered results stored in the event:
View: Form.UI.cfc

<cfset event.copyToScope(variables, "RenderResults") />
<cfif compare(variables.RenderResults,"")>
<cfoutput>
#variables.RenderResults#
</cfoutput>
</cfif>

Running this with ModelGlue reload set to true works flawlessly. When it is set to false for testing and production, the library service call to getUI.render() returns an empty string. If I call it with init=true, it will work.

I'm currently working around the problem by dropping the entire render method in an event and invoking it within my view. When I invoke it there (instead of within the controller) it works.

Does setting MG reload = false enable any whitespace management? Something about that setting seems to prevent direct HTML output within a CFC (probably not the best practice anyway, but that's the library I'm stuck with).

Any ideas?

-Joe
Reply all
Reply to author
Forward
0 new messages