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

Reply via email to