Solved

I am having problems with cfajaxproxy/railo

Posted on 2013-05-24
6
585 Views
Last Modified: 2013-08-20
I am having problems with using cfajaxproxy with railo, where by calling some of my remote functions will result in a JSONParse error being thrown in the browser. I have managed to identify which functions execute successfully and which fail and it appears to be due to the types of the parameters. Simple types such as strings and booleans work fine, i.e:

<CFFUNCTION name="activate" access="remote" output="no">
      <CFARGUMENT name="webpageId" type="string" required="yes">
      <CFARGUMENT name="isActive" type="boolean" required="yes">


However, any function which requests a struct or array as a parameter, i.e:

<CFFUNCTION name="activate" access="remote" output="no">
      <CFARGUMENT name="webpageId" type="struct" required="yes">


will result in the JSONParse error described. The same function works perfectly using CF9, but when run in the railo environment it throws that error. Does any one have any ideas as to what might be causing this? .. or suggest anything to try?

Many thanks!
0
Comment
Question by:paddycobbett
  • 3
  • 3
6 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 39202253
We'd need to see more code. Can you post a small demo example that produces the error?

What version of Railo?
0
 
LVL 1

Author Comment

by:paddycobbett
ID: 39204143
Sure, the following code runs successfully in a CF environment, yet fails in the Railo environment.  Do you have any idea why this could be?  Is is related to an environment setup issue? Could you try this is your railo environment (assuming you have one set up) and see if it works? That would eliminate it being a code issue. Am running railo 4.0.4.001


<html>
<body>
<cfajaxproxy cfc="testcfc" jsclassname="testcfc" />
<script>

 var proxy=new testcfc();
 proxy.setCallbackHandler(function(response){
  alert('string test succeeded!');
 });
 proxy.testWithString('teststring'); // succeeds
 
 proxy=new testcfc();
 proxy.setCallbackHandler(function(response){
  alert('struct test succeeded!');
 });
 proxy.testWithStruct({ struct: 'structval' }); // fails
</script>

</body>
</html>


### test.cfc

<CFCOMPONENT>

 <CFFUNCTION name="testWithString" access="remote" returnFormat="json" output="no">
  <CFARGUMENT name="stringParam" type="string" required="yes">
 
 </CFFUNCTION>
 
 <CFFUNCTION name="testWithStruct" access="remote" returnFormat="json" output="no">
  <CFARGUMENT name="structParam" type="struct" required="yes">
 
 </CFFUNCTION>

</CFCOMPONENT>
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 39206579
Interesting.  The FF debugger shows it's using the structure param as the "argumentCollection".  So what's actually passed to the function is a parameter named "struct" with a value of "structval" .  

http://localhost/testcfc.cfc?method=testWithStruct&returnFormat=json&argumentCollection={%22struct%22:%22structval%22}


For it to work, I think you need to do something like this instead:

       proxy.testWithStruct( {structParam:   { struct: 'structval' }  });
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 1

Author Closing Comment

by:paddycobbett
ID: 39209509
Worked like a charm! thanks and good insight!
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39209676
You're welcome (..and I learned something new too !)
0
 
LVL 1

Author Comment

by:paddycobbett
ID: 39425909
Hi, I know this is an old question but had a quick follow up which is not easily posed as a separate question. Since railo handles the ajax parameters differently, is there an obvious way in which I can call the ajax function that is compatible for both railo and non-railo? Just wanted to check before I adjust my calls for railo which will break if it's not run in the railo environment. I wish I could award follow up points :(
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question