<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ColdFused? &#187; tips</title>
	<atom:link href="http://www.rupeshk.org/blog/index.php/tag/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rupeshk.org/blog</link>
	<description>My Views on ColdFusion, Java and related technologies</description>
	<lastBuildDate>Mon, 21 Jun 2010 12:40:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ColdFusion ORM : Troubleshooting &#8211; &#8216;Lazy&#8217; does not work</title>
		<link>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-troubleshooting-lazy-does-not-work/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-troubleshooting-lazy-does-not-work/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 14:09:05 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[ORM]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[orm]]></category>

		<guid isPermaLink="false">http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-troubleshooting-lazy-does-not-work/</guid>
		<description><![CDATA[Few days back Manju logged a bug in CF-ORM saying &#8216;lazy&#8217; does not work for many-to-one relation and that too on non-Windows machine. At first, I simply rejected the bug because a) ORM can not have anything to do with OS and therefore, if it works on Windows, it works on all the plaform and [...]]]></description>
			<content:encoded><![CDATA[<p>Few days back <a href="http://www.manjukiran.net">Manju</a> logged a bug in CF-ORM saying &#8216;lazy&#8217; does not work for many-to-one relation and that too on non-Windows machine. At first, I simply rejected the bug because a) ORM can not have anything to do with OS and therefore, if it works on Windows, it works on all the plaform and b) I know it works <img src='http://www.rupeshk.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . But he did not agree and I had to take a look at that machine. And apparently he was right &#8211; lazy was not working ! The related entity was in-fact getting loaded immediately. (Question for you &#8211; how will you know that lazy is working or not?)</p>
<p>Even after seeing this, I did not believe it and asked him to replicate this on another system and he successfully showed that to me on one another system. And he agreed that it works fine on most of the configurations. The problem exists only on a few of the systems.</p>
<p>This got me thinking &#8211; Why would a relation get loaded immediately even after it is marked lazy? The only answer would be &#8211; if some one is accessing that lazy field and calling some method on it. I checked his code which was loading the entities to see if there could be any case, where the field would get loaded and unfortunately there was none.</p>
<p>And then suddenly it hit me &#8211; what if &#8220;memory tracking&#8221; is swithched on? That would access each of the field of each object recursively to compute the size of an object and that can definitely cause this. I immediately checked the server monitor and the &#8220;memory tracking&#8221; was right there staring at me in &#8220;red&#8221;! It was indeed enabled. I asked Manju to check the other system as well (where lazy was not working) and the memory tracking was enabled there as well.</p>
<p>So the lesson &#8211; <strong>If the &#8216;memory tracking&#8217; is enabled on the server, the relationship will no longer remain lazy</strong>. And btw, you should enable &#8220;Memory tracking&#8221; on the server only if you need to track the memory for some troubleshooting. Memory tracking is really really expensive in terms of performance.</p>
<p>Another reason why it might not work for you could be &#8211; if you are sending the object to flex. Currently, during serialization, the related objects also get sent irrespective of the lazy attribute set on the relationship. We are still working on it and hopefully by the time we release, this will be fixed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-troubleshooting-lazy-does-not-work/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>ColdFusion ORM : How to log SQL</title>
		<link>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-how-to-log-sql/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-how-to-log-sql/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 14:47:33 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[ORM]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[orm]]></category>

		<guid isPermaLink="false">http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-how-to-log-sql/</guid>
		<description><![CDATA[When you use ORM for developing an application, SQLs are generated and executed by the underlying ORM engine (i.e Hibernate for ColdFusion ORM). However, for both troubleshooting and performance optimization, it is crucial to monitor what queries are getting generated. It can help you find out if there is any error in mapping that you [...]]]></description>
			<content:encoded><![CDATA[<p>When you use ORM for developing an application, SQLs are generated and executed by the underlying ORM engine (i.e Hibernate for ColdFusion ORM). However, for both troubleshooting and performance optimization, it is crucial to monitor what queries are getting generated. It can help you find out if there is any error in mapping that you have provided as well as it can help you decide various tuning strategies. </p>
<p>ColdFusion can log the SQLs generated by ORM either onto the console or a file. At the same time it leaves enough hook for you to log it anywhere you want.</p>
<p>ColdFusion ORM provides two ways to log the SQLs.</p>
<ol>
<li>Using application setting to log to console : This is a quick and simple way to log the sql to console. This is enabled by setting &#8220;logsql&#8221; in ormsettings.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;">   <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> this.ormsettings.logsql<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;true&quot;</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>This setting is self sufficient and it will log all the sqls executed by hibernate to the console (or a file where the server output goes). However this is not a very flexible option. The sqls are always written to the console and it will be combined with any other output that goes to console. Also this option will not show the DDL queries used for creating or updating tables. It only logs the SQL for the entity operations. </p>
<li>Using log4J.properties: Hibernate uses <a href="http://logging.apache.org/log4j/">log4j</a> for its logging and you can completely control its logging (including SQL) by modifying the log4j.properties. log4j.properties is present under &lt;cf_home&gt;/lib directory. Please note that you don&#8217;t need to do any application specific setting for this. </li>
</ol>
<p>&nbsp;</p>
<p>I will go in details about using log4j.properties for SQL logging. Here is a snippet from log4j.properties file that is shipped with ColdFusion.</p>

<div class="wp_syntax"><div class="code"><pre class="properties" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">###--------------- Hibernate Log Settings ------ </span>
<span style="color: #808080; font-style: italic;">### Set Hibernate log </span>
<span style="color: #000080; font-weight:bold;">log4j.logger.org.hibernate</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">ERROR, HIBERNATECONSOLE </span>
&nbsp;
<span style="color: #808080; font-style: italic;">### log just the SQL </span>
<span style="color: #808080; font-style: italic;">#log4j.logger.org.hibernate.SQL=DEBUG, HIBERNATECONSOLE </span>
<span style="color: #808080; font-style: italic;">#log4j.additivity.org.hibernate.SQL=false </span>
<span style="color: #808080; font-style: italic;">### Also log the parameter binding to the prepared statements. </span>
<span style="color: #808080; font-style: italic;">#log4j.logger.org.hibernate.type=DEBUG </span>
<span style="color: #808080; font-style: italic;">### log schema export/update ### </span>
<span style="color: #000080; font-weight:bold;">log4j.logger.org.hibernate.tool.hbm2ddl</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">DEBUG, HIBERNATECONSOLE </span>
<span style="color: #808080; font-style: italic;">### log cache activity ### </span>
<span style="color: #000080; font-weight:bold;">log4j.logger.org.hibernate.cache</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">ERROR, HIBERNATECONSOLE </span>
&nbsp;
<span style="color: #808080; font-style: italic;"># HibernateConsole is set to be a ColsoleAppender for Hibernate message  using a PatternLayout. </span>
<span style="color: #000080; font-weight:bold;">log4j.appender.HIBERNATECONSOLE</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">org.apache.log4j.ConsoleAppender </span>
<span style="color: #000080; font-weight:bold;">log4j.appender.HIBERNATECONSOLE.layout</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">org.apache.log4j.PatternLayout </span>
<span style="color: #000080; font-weight:bold;">log4j.appender.HIBERNATECONSOLE.layout.ConversionPattern</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">%d<span style="">&#123;</span>MM/dd HH:mm:ss<span style="">&#125;</span> <span style="">&#91;</span>%t<span style="">&#93;</span> HIBERNATE %-5p - %m%n%n </span>
<span style="color: #808080; font-style: italic;">#---------------------------------------------</span></pre></div></div>

<p>First we will see the relevant settings for SQL logging:</p>
<ul>
<li>log4j.logger.org.hibernate.SQL : Defines whether the SQL executed for entity operations will be logged and where it will be logged. The second value for this i.e &#8216;HIBERNATECONSOLE&#8217; is a appender that controls <strong>where</strong> the SQLs will be logged. In the above example HIBERNATECONSOLE is a &#8216;console&#8217; appender which means it will log the sql to console.
<li>log4j.logger.org.hibernate.type : Defines whether parameter values used for parametrized query will be logged.
<li>log4j.logger.org.hibernate.tool.hbm2ddl : Defines whether DDL sql statements will be logged. </li>
</ul>
<p>To enable the SQL logging for console, we just need to uncomment the settings mentioned above. Here is how the hibernate log settings in log4j.properties file would look like</p>

<div class="wp_syntax"><div class="code"><pre class="properties" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">###--------------- Hibernate Log Settings ------ </span>
<span style="color: #808080; font-style: italic;">### Set Hibernate log </span>
<span style="color: #000080; font-weight:bold;">log4j.logger.org.hibernate</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">ERROR, HIBERNATECONSOLE </span>
&nbsp;
<span style="color: #808080; font-style: italic;">### log just the SQL </span>
<span style="color: #000080; font-weight:bold;">log4j.logger.org.hibernate.SQL</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">DEBUG, HIBERNATECONSOLE </span>
<span style="color: #000080; font-weight:bold;">log4j.additivity.org.hibernate.SQL</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">false </span>
<span style="color: #808080; font-style: italic;">### Also log the parameter binding to the prepared statements. </span>
<span style="color: #808080; font-style: italic;">#log4j.logger.org.hibernate.type=DEBUG </span>
<span style="color: #808080; font-style: italic;">### log schema export/update ### </span>
<span style="color: #000080; font-weight:bold;">log4j.logger.org.hibernate.tool.hbm2ddl</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">DEBUG, HIBERNATECONSOLE </span>
<span style="color: #808080; font-style: italic;">### log cache activity ### </span>
<span style="color: #000080; font-weight:bold;">log4j.logger.org.hibernate.cache</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">ERROR, HIBERNATECONSOLE </span>
&nbsp;
<span style="color: #808080; font-style: italic;"># HibernateConsole is set to be a ColsoleAppender for Hibernate message  using a PatternLayout. </span>
<span style="color: #000080; font-weight:bold;">log4j.appender.HIBERNATECONSOLE</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">org.apache.log4j.ConsoleAppender </span>
<span style="color: #000080; font-weight:bold;">log4j.appender.HIBERNATECONSOLE.layout</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">org.apache.log4j.PatternLayout </span>
<span style="color: #000080; font-weight:bold;">log4j.appender.HIBERNATECONSOLE.layout.ConversionPattern</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">%d<span style="">&#123;</span>MM/dd HH:mm:ss<span style="">&#125;</span> <span style="">&#91;</span>%t<span style="">&#93;</span> HIBERNATE %-5p - %m%n%n </span>
<span style="color: #808080; font-style: italic;">#---------------------------------------------</span></pre></div></div>

<p><a href="http://www.rupeshk.org/misc/2507/1/log4j.txt">Here is the complete log4j.properties</a> for logging SQL for console. Ofcourse after changing this you need to restart the server. If you need to log the parameter values used for queries, you need to uncomment &#8216;#log4j.logger.org.hibernate.type=DEBUG&#8217; as well. </p>
<p>What if you want to log the SQL to a file and not to console? That is pretty easy. You just need to change the &#8216;Appender&#8217; used here (HIBERNATECONSOLE) to point to a &#8216;FileAppender&#8217; instead of a ConsoleAppender. Here is how the configuration for HIBERNATECONSOLE should look like after you point it to a File Appender. </p>

<div class="wp_syntax"><div class="code"><pre class="properties" style="font-family:monospace;"><span style="color: #000080; font-weight:bold;">log4j.appender.HIBERNATECONSOLE</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">org.apache.log4j.FileAppender</span>
<span style="color: #000080; font-weight:bold;">log4j.appender.HIBERNATECONSOLE.File</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">../hibernatesql.log</span>
<span style="color: #000080; font-weight:bold;">log4j.appender.HIBERNATECONSOLE.Append</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">true</span>
<span style="color: #000080; font-weight:bold;">log4j.appender.HIBERNATECONSOLE.layout</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">org.apache.log4j.PatternLayout</span>
<span style="color: #000080; font-weight:bold;">log4j.appender.HIBERNATECONSOLE.layout.ConversionPattern</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">%d<span style="">&#123;</span>MM/dd HH:mm:ss<span style="">&#125;</span> <span style="">&#91;</span>%t<span style="">&#93;</span> HIBERNATE %-5p - %m%n%n</span></pre></div></div>

<p>For standalone ColdFusion installation, the file &#8216;hibernatesql.log&#8217; will be created in the <cfhome>/logs directory.You can also specify a full path of the file for property &#8216;log4j.appender.HIBERNATECONSOLE.File&#8217; and the log will be written to that.</p>
<p>That was easy. Isn&#8217;t it? What if you want a rolling log file where you dont want the log file size to grow infinitely. That is fairly easy too. All you need to do is to use an appropriate appender. The appender definition for that will look like</p>

<div class="wp_syntax"><div class="code"><pre class="properties" style="font-family:monospace;"><span style="color: #000080; font-weight:bold;">log4j.appender.HIBERNATECONSOLE</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">org.apache.log4j.RollingFileAppender</span>
<span style="color: #000080; font-weight:bold;">log4j.appender.HIBERNATECONSOLE.File</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">../hibernatesql.log</span>
<span style="color: #000080; font-weight:bold;">log4j.appender.HIBERNATECONSOLE.Append</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">true</span>
<span style="color: #000080; font-weight:bold;">log4j.appender.HIBERNATECONSOLE.MaxFileSize</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">500KB</span>
<span style="color: #000080; font-weight:bold;">log4j.appender.HIBERNATECONSOLE.MaxBackupIndex</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">3</span>
<span style="color: #000080; font-weight:bold;">log4j.appender.HIBERNATECONSOLE.layout</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">org.apache.log4j.PatternLayout</span>
<span style="color: #000080; font-weight:bold;">log4j.appender.HIBERNATECONSOLE.layout.ConversionPattern</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">%d<span style="">&#123;</span>MM/dd HH:mm:ss<span style="">&#125;</span> <span style="">&#91;</span>%t<span style="">&#93;</span> HIBERNATE %-5p - %m%n%n</span></pre></div></div>

<pre></pre>
<p><a href="http://www.rupeshk.org/misc/2507/2/log4j.txt">Here is the complete log4j.properties</a> for logging SQL to a file that will be rolled automatically once it reaches 500KB.</p>
<p>Now that you have seen how easy it is to change one &#8216;Appender&#8217; to another, you can pretty much log it anywhich way you want. Here are some of the interesting &#8216;Appender&#8217;s that come with log4j which you can easily use.</p>
<p><a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/DailyRollingFileAppender.html">DailyRollingFileAppender</a>, <a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/varia/ExternallyRolledFileAppender.html">ExternallyRolledFileAppender</a>, <a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/net/JMSAppender.html">JMSAppender</a>, <a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/net/SMTPAppender.html">SMTPAppender</a>, <a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/net/SocketAppender.html">SocketAppender</a>, <a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/net/SyslogAppender.html">SyslogAppender</a></p>
<p>See <a href="http://logging.apache.org/log4j/1.2/index.html">log4J</a> for more details on log4j settings.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-how-to-log-sql/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Reading Flash (Swf) metadata from ColdFusion</title>
		<link>http://www.rupeshk.org/blog/index.php/2008/02/reading-flash-swf-metadata-from-coldfusion/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2008/02/reading-flash-swf-metadata-from-coldfusion/#comments</comments>
		<pubDate>Fri, 15 Feb 2008 17:34:00 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://rupesh106.wordpress.com/2008/02/15/reading-flash-swf-metadata-from-coldfusion/</guid>
		<description><![CDATA[Wouldn&#8217;t it be cool if you could read the meta-data of Swf file in ColdFusion? The most common use case I can think of is to find the dimension of swf movie so that you can set the dimension for the same in object tag while you are embedding the flash movie in your page. [...]]]></description>
			<content:encoded><![CDATA[<p>Wouldn&#8217;t it be cool if you could read the meta-data of Swf file in ColdFusion? The most common use case I can think of is to find the dimension of swf movie so that you can set the dimension for the same in object tag while you are embedding the flash movie in your page. And the good news is that you can do that currently in ColdFusion with just 2-3 lines of code!! All you need to do is to create a TagDecoder and decoder the header with it. Here is the complete code.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #000099;">  fis <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">createObject</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;java&quot;</span>, <span style="color: #009900;">&quot;java.io.FileInputStream&quot;</span><span style="color: #0000FF;">&#41;</span>.init<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;C:<span style="color: #009900;">\t</span>est.swf&quot;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;"> <span style="color: #808080; font-style: italic;">// Create the FileInputStream</span></span>
<span style="color: #000099;">  decoder <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">createObject</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;java&quot;</span>, <span style="color: #009900;">&quot;macromedia.swf.TagDecoder&quot;</span><span style="color: #0000FF;">&#41;</span>.init<span style="color: #0000FF;">&#40;</span>fis<span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;"> <span style="color: #808080; font-style: italic;">// create TagDecoder</span></span>
<span style="color: #000099;"> <span style="color: #0000FF;">header</span> <span style="color: #0000FF;">=</span> decoder.decodeHeader<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span>; </span>
<span style="color: #000099;"><span style="color: #808080; font-style: italic;">// Decode the header.</span></span>
<span style="color: #000099;">fis.close<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span>; </span>
<span style="color: #000099;">rect <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">header</span>.<span style="color: #0000FF;">size</span>;</span>
<span style="color: #000099;"><span style="color: #800080; font-weight: bold;">WriteOutput</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;</span>
<span style="color: #000099;">    Is Compressed : #header.compressed#&lt;br&gt;</span>
<span style="color: #000099;">    Frame Count : #header.framecount#&lt;br&gt;</span>
<span style="color: #000099;">    Frame rate : #header.rate#&lt;br&gt;</span>
<span style="color: #000099;">    Version : #header.version#&lt;br&gt;</span>
<span style="color: #000099;">    Height : #rect.getHeight()#&lt;br&gt;</span>
<span style="color: #000099;">    Width : #rect.getWidth()#&quot;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p></p>
<p>
The height and width value that you see here would be in <a href="http://en.wikipedia.org/wiki/Twips">twips</a> which is defined as 1/20 of a point or 1/1440 inch. This means, for a 72 dpi screeen, you will have to divide it by 20 to get the height and width in pixels.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2008/02/reading-flash-swf-metadata-from-coldfusion/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>ColdFusion 8 : IsInstanceOf</title>
		<link>http://www.rupeshk.org/blog/index.php/2007/08/coldfusion-8-isinstanceof/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2007/08/coldfusion-8-isinstanceof/#comments</comments>
		<pubDate>Thu, 02 Aug 2007 22:52:00 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://rupesh106.wordpress.com/2007/08/02/coldfusion-8-isinstanceof/</guid>
		<description><![CDATA[If you use lot of CFC inside your ColdFusion application, I am sure you would have come across a situation where you would need to know whether the object is an instance of a particular CFC. This is specially needed when you have components extending other component or you are passing the objects around. ColdFusion [...]]]></description>
			<content:encoded><![CDATA[<p>If you use lot of CFC inside your ColdFusion application, I am sure you would have come across a situation where you would need to know whether the object is an instance of a particular CFC. This is specially needed when you have components extending other component or you are passing the objects around. ColdFusion 8 introduces a new function <b>IsInstanceOf</b> to do exactly the same. It becomes even more useful after we have interfaces in ColdFusion. And the icing on the cake is that it works even with java objects which means that you can use this function to find out if a particular object is of a particular java class type.</p>
<p>Here is how the function looks.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;">IsInstanceOf(object, typeName)</pre></div></div>

<p>where typeName is name of the component/Interface or fully qualified java class name.</p>
<p>It returns &#8216;true&#8217; if</p>
<ul>
<li>The object passed is an instance of a component which is same as specified type or inherits it or implements the specified interface. Just to be clear, a component &#8216;A&#8217; inherits a component &#8216;B&#8217; if A or any of its super component extends &#8216;B&#8217;. Similarly a Component &#8216;A&#8217; implements an interface &#8216;B&#8217; if A or any of its super component, implements interface &#8216;B&#8217; or any of the interface that &#8216;A&#8217; or its parents implement, extends from the specified interface.
</li>
<li>The object passed is an instance of a java class (created using cfobject or createObject for java class) which is same as specified class name or inherits the specified class name or implements the specified interface.
</li>
</ul>
<p>Here is an example</p>
<p><b>Intf.cfc</b></p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfinterface</span><span style="color: #0000FF;">&gt;</span></span>
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;foo&quot;</span><span style="color: #0000FF;">&gt;</span></span>
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfinterface</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>
<b>Comp.cfc</b></p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfcomponent</span> implements<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;Intf&quot;</span><span style="color: #0000FF;">&gt;</span></span>
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;foo&quot;</span><span style="color: #0000FF;">&gt;</span></span>
        <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>In method foo<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfcomponent</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>
<b>test.cfm</b></p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> obj <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">CreateObject</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;Component&quot;</span>, <span style="color: #009900;">&quot;Comp&quot;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!--- Create a Java object ---&gt;</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> javaObj <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">CreateObject</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;java&quot;</span>, <span style="color: #009900;">&quot;java.lang.StringBuffer&quot;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>object is of type Comp : #IsInstanceOf(obj, &quot;Comp&quot;)#<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;&lt;</span><span style="color: #000000;">br</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>object is of type Intf : #IsInstanceOf(obj, &quot;Intf&quot;)#<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;&lt;</span><span style="color: #000000;">br</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>java object is of type String : #IsInstanceOf(javaobj, &quot;java.lang.String&quot;)#<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;&lt;</span><span style="color: #000000;">br</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>java object is of type StringBuffer : #IsInstanceOf(javaobj, &quot;java.lang.StringBuffer&quot;)#<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;&lt;</span><span style="color: #000000;">br</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2007/08/coldfusion-8-isinstanceof/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ListToArray in ColdFusion 8</title>
		<link>http://www.rupeshk.org/blog/index.php/2007/07/listtoarray-in-coldfusion-8/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2007/07/listtoarray-in-coldfusion-8/#comments</comments>
		<pubDate>Fri, 20 Jul 2007 03:00:00 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://rupesh106.wordpress.com/2007/07/19/listtoarray-in-coldfusion-8/</guid>
		<description><![CDATA[There has been lots and lots of discussion in CF blogs and forums about ListToArray not supporting empty elements. Seeing which I had blogged about a simple way which could do the same. Thanks to Charlie Griefer for pointing out the problem in it and then thanks to Ben Nadel and Andrew Clark for pointing [...]]]></description>
			<content:encoded><![CDATA[<p>There has been lots and lots of discussion in CF blogs and forums about ListToArray not supporting empty elements. Seeing which I had <a href="http://coldfused.blogspot.com/2007/06/listtoarray-with-empty-elements.html" target="_blank">blogged</a> about a simple way which could do the same. Thanks to <a href="http://cfblog.griefer.com/index.cfm/id/make_like_a_banana_and_split" target="_blank">Charlie Griefer</a> for pointing out the problem in it and then thanks to <a href="http://www.bennadel.com/blog/492-Caution-Java-String-Split-Does-Not-Create-A-ColdFusion-Array.htm" target="_blank">Ben Nadel</a> and Andrew Clark for pointing me in the right direction.
<p>Though it got pretty late, I was able to sneak-in this change in ColdFusion 8. ListToArray() now takes an additional optional argument &#8220;includeEmptyElements&#8221;, which if &#8216;true&#8217; will include the empty elements of list into the array. Default is of course &#8216;false&#8217;. It also takes care of empty elements at the end of list and multiple delimiters. Here is how the function looks</p>
<pre>ListToArray(list, delimiter, includeEmptyElements) returns Array</pre>
<p>Lets take a look at couple of examples to see it working</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> <span style="color: #0000FF;">list</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;a,b,,c, ,d,,&quot;</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> arr <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">ListToArray</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">list</span>, <span style="color: #009900;">','</span>, true<span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfdump</span> <span style="color: #0000ff;">var</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#arr#&quot;</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>Here is how the output looks.<br /><img src="http://2.bp.blogspot.com/_bIpyKqHMpHg/Rp_DXc1DBAI/AAAAAAAAAAs/qe3dWdftC7s/s320/list2arr1.JPG" alt="" border="0" /></a></p>
<p>Here is another example.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> <span style="color: #0000FF;">list</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;one,/$/,six&quot;</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> arr <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">listToArray</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">list</span>, <span style="color: #009900;">&quot;,$/&quot;</span>,true<span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfdump</span> <span style="color: #0000ff;">var</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#arr#&quot;</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>
<p>The output for which looks like this</p>
<p><img src="http://4.bp.blogspot.com/_bIpyKqHMpHg/Rp_Dr81DBBI/AAAAAAAAAA0/0k_D-vOrVog/s320/list2arr2.JPG" alt="" border="0" /></a></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p>Though we wanted to, there was just not enough time to make similar change in all the list functions for CF 8. Something for CF 9 <img src='http://www.rupeshk.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2007/07/listtoarray-in-coldfusion-8/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
