Copy link to clipboard
Copied
I am trying to integrate some .NET business objects into ColdFusion but have run into a problem with ColdFusion always making my method calls upper case.
Here is the snipper of code I am having issues with.
objCustomer = CreateObject(".NET", "TestLibrary.BusinessObjects.Customer", "TestLibrary.dll");
objCustomer.FirstName = "El";
objCustomer.LastName = "Heffe";
objCustomer.CustomerType = "Deviant";
When the page is ran the error message is
Element FIRSTNAME is undefined in OBJCUSTOMER. | |||||||||
The error occurred in C:\Inetpub\wwwroot\Test\wsTest.cfm: line 28 | |||||||||
26 : </cfscript> | |||||||||
Resources:
| |||||||||
|
Stack Trace |
at cfwsTest2ecfm1594120296.runPage(C:\Inetpub\wwwroot\Test\wsTest.cfm:28) coldfusion.runtime.UndefinedElementException: Element FIRSTNAME is undefined in OBJCUSTOMER. |
The variables I am trying to set in the .NET object are getter/setter methods and are used in the test .NET application just fine.
Why is ColdFusion upper casing the method call? My guess it has to due with dot notion and how it works when creating cf structures. How do I get around this "functionality"
Thanks.
Copy link to clipboard
Copied
Try associative array notation: objCustomer["FirstName"].
I dunno why CF monkeys with the casing of variable names / struct keys when using dot notation. Probably some necessity to implement CF's caselessness with Java.
--
Adam
Copy link to clipboard
Copied
Getting closer to having it work. Have found that with Getter/Setter methods ColdFusion interacts with them differently. Still trying to figure out how to get a enum to work.
Here is an updated code snippet.
objCustomer = CreateObject(".NET", "TestLibrary.BusinessObjects.Customer", "TestLibrary.dll");
objCustomerType = CreateObject(".NET", "TestLibrary.Enums.CustomerType", "TestLibrary.dll");objCustomer.Set_FirstName("El");
Copy link to clipboard
Copied
Figured out enums so one to other issues. Here is the code if anyone else needs an answer.
objCustomer = CreateObject(".NET", "TestLibrary.BusinessObjects.Customer", "TestLibrary.dll");
objCustomerType = CreateObject(".NET", "TestLibrary.Enums.CustomerType", "TestLibrary.dll");
objCustomer.Set_FirstName("El");
objCustomer.Set_LastName("Heffe");
objCustomer.Set_CustomerType(objCustomerType.Sad);