Re: [railo] cfajaxproxy problem

139 views
Skip to first unread message

Andrea Campolonghi

unread,
May 24, 2013, 10:06:52 AM5/24/13
to ra...@googlegroups.com
Here is some examples:

Maybe is can help.
If not please provide a working test case to reproduce the issue.

Thanks

Andrea

On May 24, 2013, at 3:04 PM, Gareth Jones <gare...@gmail.com> wrote:

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 CF8, 9 & 10, 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!

--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
 
 
If you don't have time, add a request to the Railo Server wiki to-do page at https://github.com/getrailo/railo/wiki/Todo
---
You received this message because you are subscribed to the Google Groups "Railo" group.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Andrea Campolonghi



Gareth Jones

unread,
May 24, 2013, 11:17:15 AM5/24/13
to ra...@googlegroups.com
Hi Andrea 

Thanks for your quick response.

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?

Many thanks 

Gareth 

<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>

Andrea Campolonghi

unread,
May 24, 2013, 12:25:14 PM5/24/13
to ra...@googlegroups.com
Please verify these things:

* what is actually sent via ajax
* what exactly arrives in the cfc function
* what exactly comes back

You told me about a parsing JSON issue that is possibly to happen on client side on callback.


Thanks

Andrea

Gareth Jones

unread,
May 24, 2013, 1:09:37 PM5/24/13
to ra...@googlegroups.com
Hi Andrea 

Would it be possible for you to quickly run the code in your Ralio environment to see if it executes successfully in order to rule out the possibility of it being an environmental / config related problem as a opposed to a code issue.

Many thanks

Gareth 

Andrea Campolonghi

unread,
May 26, 2013, 11:36:20 AM5/26/13
to ra...@googlegroups.com
Gareth,

please run the code and trace/dump what you are actually sending, what you get in the cfc function and what you get back.

Feel free to post more info here so that I can try to help.

Andrea

Andrea Campolonghi

unread,
May 27, 2013, 3:43:16 AM5/27/13
to ra...@googlegroups.com
Debugging the ajax call you realize that the arguments are passed in a literally translated argumentCollection.
This means that what you send is converted to a struct on railo side.

proxy=new testcfc();
 proxy.setCallbackHandler(function(response){
  alert('struct test succeeded!');
 });
 proxy.testWithStruct({structParam : { struct: 'structval' }}); // fails

This will work.

Andrea

Andrea Campolonghi



Reply all
Reply to author
Forward
0 new messages