MG3: Problem with remoting service

9 views
Skip to first unread message

Chris Blackwell

unread,
May 16, 2009, 9:56:44 AM5/16/09
to model...@googlegroups.com
I'm just having a quick fiddle with the RemotingService.cfc and straight away i've hit a problem, possibly a bug...

I have an event that gets a list of items, and the view template uses a custom tag to display them.  The custom tag uses <cfhtmlhead> to throw its js & css into the page.  However when i execute this event via the remoting service the js/css is still sent to the output stream, so my json packet is fubar'd.

Steps to reproduce:

1) edit a view template and add the following tag anywhere in the template 
    <cfhtmlhead text="oooh dear!!" />

2) execute an event that includes the above view using RemotingService

3) you should see output similar to the following   
 oooh dear!!<wddxPacket version='1.0'><header/><data><struct></struct></data></wddxPacket>

I don't know whether there is anyway around this.  As far as i can tell <cfhtmlhead> is one of the final tags executed before the content is returned to the browser and theres no way to clear it from the the request. The test page below will still output "foo"

test.cfm
<cfhtmlhead text="foo">
<cfcontent reset="yes">

Is it worth filing this as a bug?

Chris

Chris Blackwell

unread,
May 16, 2009, 11:29:02 AM5/16/09
to model...@googlegroups.com
Added as bug #339 including fix


2009/5/16 Chris Blackwell <ch...@team193.com>

Dan Wilson

unread,
May 16, 2009, 11:40:52 AM5/16/09
to model...@googlegroups.com
Cool Chris!

Thanks for the patch. I'll contact you directly If I have any questions.

:)

Dan

On 5/16/09, Chris Blackwell <ch...@team193.com> wrote:
> Added as bug #339 including fixhttp://trac.model-glue.com/ticket/339
--
“Come to the edge, he said. They said: We are afraid. Come to the
edge, he said. They came. He pushed them and they flew.”

Guillaume Apollinaire quotes

Ezra Parker

unread,
May 16, 2009, 12:02:41 PM5/16/09
to model...@googlegroups.com
Hey Chris,

I just took a quick look at your suggested patch, and wanted to raise
a concern, which is the fact that it leverages an implementation that
is only present in Adobe ColdFusion, and therefore will break under
Railo or (I think) OpenBD. For example, on line 49:

<cfloop condition="getMetaData(out).getName() is
'coldfusion.runtime.NeoBodyContent'">

Personally, I would very much prefer that Model-Glue remain CFML
engine agnostic, so I wonder if there is a way to solve this issue
that doesn't require a vendor-specific implementation...

--
Ezra Parker

Chris Blackwell

unread,
May 16, 2009, 1:03:58 PM5/16/09
to model...@googlegroups.com
Yeah, i should have mentioned that.  An engine agnostic solution would basically mean written in CFML, and i wasn't able to find a way to do that. 

Without changing the way remoting has been implemented i can't see a way round this, and even then i'm not sure what you'd do to stop cfhtmlhead injecting into the output stream.

Seems this is a little bit of a problem

Chris



2009/5/16 Ezra Parker <ez...@cfgrok.com>

Chris Blackwell

unread,
May 17, 2009, 6:37:20 AM5/17/09
to model...@googlegroups.com
Okay, so I must have too much free time at the moment or something,  but I've updated the function to work on CF8, Railo 3.1 and OpenBD1.1  Those are the only engines I've tested on so it may well break on others, but I thought it worth while sharing what I've discovered in case its a workable solution to this problem or others reading this thread in the future may find it helpful.

I've attached 3 files, the UDF plus a cfm and cfc test.  There are differences in the pagecontext depending on whether the call is made from a cfm or a cfc, and even whether the cfc has output=true/false, hence the separate test cases.

The UDF doesn't check the product version only the server.coldfusion.productname key and switches on that.  Its not very clever i know, so if anyone has a suggestion on how that could be made more robust then i'd welcome it.

Chris

htmlheadtest.cfc
htmlheadtest.cfm
resetCFHtmlHead.cfm

Chris Blackwell

unread,
May 17, 2009, 10:49:06 AM5/17/09
to model...@googlegroups.com
I've also discovered that invoking an event using the RemotingService.cfc does not fire populateEventContext in the PopulationController (url, form, request) so any values you want to pass in on the url, for example criteria for a genericlist message are not found.

The "values" paramater of AbstractRemotingService.executeEvent() accepts a struct, but its not possible to pass a struct to CF over the url, so this isn't much use for ajax.

Chris
Reply all
Reply to author
Forward
0 new messages