Re: Using isDefined/StructKeyExists against a ,Net com object

2010-11-24 Thread Pete Jordan

Joanne Corless wrote:

 I'm doing some .Net integration and the values of the .Net object returned 
 need to be inspected and then displayed if they are defined

 I've found that the conversion process brings everything back as 
 rootObject.Get_ObjectName().Get_Value() which blows up if the object is empty 
 throwing an undefined error - However if I try and use 
 isDefined(rootObject.Get_ObjectName) or 
 StructKeyExists(rootObject,Get_ObjectName) - it just doesn't work - If I add 
 in the () at the end - it blows up Coldfusion

 I can't just display everything because there may be elements that are empty 
 - Has anyone else had this problem  have a solution? 
   

An alternative to wrapping in a cftry block is cfparam, something like:

 cfparam name=rootObject.Get_ObjectName default=undefined!/

 cfif isSimpleValue(rootObject.Get_ObjectName)
   !--- it's undefined! ---
 cfelse
  cfset theValue=rootObject.Get_ObjectName().Get_Value()/
 /cfif

I use a similar mechanism to cope with accessing elements in sparse
arrays (though I default to #server.undefined#, which is a Java object I
create for just this sort of purpose); it should work for your problem too.

-- 
Regards,

Pete Jordan
Horus Web Engineering Ltd
http://www.webhorus.net/
phone: +44 1482 446471
mobile: +44 7973 725120


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339496
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Using isDefined/StructKeyExists against a ,Net com object

2010-11-22 Thread Joanne Corless

I'm doing some .Net integration and the values of the .Net object returned need 
to be inspected and then displayed if they are defined

 

I've found that the conversion process brings everything back as 
rootObject.Get_ObjectName().Get_Value() which blows up if the object is empty 
throwing an undefined error - However if I try and use 
isDefined(rootObject.Get_ObjectName) or 
StructKeyExists(rootObject,Get_ObjectName) - it just doesn't work - If I add 
in the () at the end - it blows up Coldfusion

 

I can't just display everything because there may be elements that are empty - 
Has anyone else had this problem  have a solution? 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339434
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Using isDefined/StructKeyExists against a ,Net com object

2010-11-22 Thread Dave Watts

 I've found that the conversion process brings everything back as 
 rootObject.Get_ObjectName().Get_Value() which blows up if the
 object is empty throwing an undefined error - However if I try and use 
 isDefined(rootObject.Get_ObjectName) or
 StructKeyExists(rootObject,Get_ObjectName) - it just doesn't work - If I add 
 in the () at the end - it blows up Coldfusion

Use cftry/cfcatch around your calls to
rootObject.Get_ObjectName().Get_Value() instead of trying to treat the
values within your object as if they were structures, etc.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339435
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm