Download CFBuilder 2 ide_config XML Schema (XSD)

Couldn’t find any XML Schema for the CFBuilder 2 extension file ide_config.xml, so I decided to create one myself during Christmas. Why? Well a good XML Schema provides code assist and inside within Eclipse, which means faster coding and more important, less coding errors. 

Don’t know why Adobe didn’t provide us with a XSD though, or did they ...?

Anyways, below a video which shows code assist within Eclipse incase you didn’t get the picture yet. I’m using the XML Editor of Eclipse, so didn’t test the one from Adobe/Aptana.

CFBuilder XML Schema - Eclipse Code Assist

Ready to Rumble? Setting it all up is pretty easy:

  1. Download the zip which contains the XSD file (updated);
  2. Copy the ide_config.xsd file to the folder where your ide_config.xml lives;
  3. Replace the application xml tag with the code snippet below;
  4. (Re)open your ide_config.xml file;
  5. Ready, you can now press CTRL+SPACE for code assist.
   1: <?xml version="1.0" encoding="UTF-8"?>
   2: <application xsi:noNamespaceSchemaLocation="ide_config.xsd"
   3:     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

Convert RTF to Plain TEXT....Java Swing rescue

You want to convert RTF to plain text? Here's the code:


<cffunction name="getPlainTextFromRichText" access="public" returntype="string" output="false">
    <cfargument name="richText" type="string" required="true">
    <cfscript>
        var RTFEditorKit = CreateObject("java","javax.swing.text.rtf.RTFEditorKit").init();
        var styledDocument = CreateObject("java","javax.swing.text.DefaultStyledDocument").init();
        var reader = CreateObject("java","java.io.StringReader").init(arguments.richText);
        
        RTFEditorKit.read(reader,styledDocument,0);
        return styledDocument.getText(0,styledDocument.getLength());        
    
</cfscript>
</cffunction>

If you know a better solution, please let me know...

....and to strip HTML tags and let Java do the regex..:


<cffunction name="getPlainTextFromHTML" access="public" returntype="string" output="false">
    <cfargument name="html" type="string" required="true">
    <cfscript>
        var HTMLEditorKit = CreateObject("java","javax.swing.text.html.HTMLEditorKit").init();
        var styledDocument = CreateObject("java","javax.swing.text.html.HTMLDocument").init();
        var reader = CreateObject("java","java.io.StringReader").init(arguments.html);
        
        HTMLEditorKit.read(reader,styledDocument,0);
        return styledDocument.getText(0,styledDocument.getLength());        
    
</cfscript>
</cffunction>

ColdBox JQueryUI Plugin

I work quite a lot with JQueryUI 1.8 lately, so time has come to create a new CB plugin. The JQueryUI Plugin handles (core)JS dependencies and CSS links for you, so no CFHTMLHEADs in your views anymore to include the proper files. You can just write:

<cfscript>
jQueryUI = getPlugin("JQueryUI",true);
jQueryUI.setEnableWidget('tabs');
</cfscript>
...or to enable multiple widgets at once:
jQueryUI.setEnableWidgets('tabs,datepicker');
What about effects and adding different ones along your code? Well, you can keep adding them and the plugin handles the boring stuff for you.
<cfscript>
jQueryUI.setEnableEffect('bounce');
// other code
jQueryUI.setEnableEffects('bounce,blind');
// other code
jQueryUI.setEnableEffect('explode');
</cfscript>
Adding interactions is rather simple as well. The following enables 'droppable and sortable' and includes the proper core JS files for you.
jQueryUI.setEnableInteractions('droppable,sortable');
What if you only need one specific core file only?
jQueryUI.setEnableCore('ui.position');
If you want to know which effects/widgets are supported by the plugin, you could use CFDUMP e.g.
<cfdump var="#jQueryUI.getEffectNames()#">
<cfdump var="#jQueryUI.getWidgetNames()#">
Ok, we're almost done. What if you want to add your own CSS file which overrides style definitions from the core CSS?
jQueryUI.setCustomCssLink('includes/css/mytabs.css');
...which is exactly the same as:
jQueryUI.setCustomCssLink(href='includes/css/mytabs.css',media='screen',renderPosition=arrayLen(jQueryUI.getCustomCssLinks()));
As you noticed in the code above, we used an attribute 'renderPosition'. this attribute gives you control over the order how the CSS links are rendered. Having control over the rendering order is rather important for JS files (Thanks bro Tom de Man for notifying......or 'G. Ramsey' for the insiders). So let's say you have a couple of JS files which you're adding along your code and you want the last JS file being rendered as first.
<cfscript>
jQueryUI.setCustomJsLink('includes/js/myfile1.js');
jQueryUI.setCustomJsLink('includes/js/myfile2.js');
jQueryUI.setCustomJsLink(src='includes/js/myfile3.js',renderPosition=( arrayLen(jQueryUI.getCustomJsLinks() )-1 ));
jQueryUI.setCustomJsLink(src='includes/js/myfile4.js',renderPosition=2);
// first position
jQueryUI.setCustomJsLink(src='includes/js/myfile5.js',renderPosition=1);
</cfscript>
Ok, all features discussed. Still interested?...let's set everything up.
  • Grab the JQueryUI plugin from RIAForge and place it into your plugin folder
  • Download jqueryui 1.8.1, unzip it into your includes folder (See screenshot below)

    image
  • Add the following lines to your coldbox config file
    <!-- Path to jQueryUI library, e.g. includes/jqueryui -->
    <setting name="JQueryUIPlugin.baseRelativePath" value="includes/jQueryUI" />
    <!--
    <Setting name="JQueryUIPlugin.cssRelativePath" value="includes/jQueryUI/themes/ui-lightness" />
    <Setting name="JQueryUIPlugin.jsRelativePath" value="includes/jQueryUI/ui/minified" />
    <Setting name="JQueryUIPlugin.jsFileNameSuffix" value=".min" />
    -->

  • Place this code somewhere in your layout file. This renders the output of the plugin.
    <cfoutput>#getPlugin("JQueryUI",true).render()#</cfoutput>
Enjoy!

ColdBox Book Released and READY for Purchase!

THE ColdBox Book has been released and is available for purchase. And YES it will be in ALL online book retails in 4-8 weeks.

Thanks Luis for putting this masterpiece together!!

Check out the ColdBox blog post for details.

Europe's First Official ColdBox Training 22-24 October in AMSTERDAM!

Tom de Manincor, my colleague and ColdBox Team Member, will give a 101+ ColdBox course in our office in Amsterdam.

If you want to know the ins,outs and best practices of ColdBox, you should definitely attend Europe's first official ColdBox Course.

....and you finally have a good excuse to visit Amsterdam :-)

 Please check out Tom's blog for the ColdBox Course details

UPDATE

Well, it's NOT the first CB course in Europe, Luis gave one at CFUG in Munich last year.

...thanks Chris for notifying!

 

IE auto content fit IFrame HACK

I ran into 'another' strange IE-browser behavior yesterday. It took me an hour of two to solve this iframe-height-problem.

If you call this.document.body.scrollHeight in an iframe twice, the first value is wrong, but the second value is okay.

Look at the example below:


    function autoFitIFrame(elementId){
        if (!window.opera && !document.mimeType && document.all && document.getElementById){
            parent.document.getElementById(elementId).style.height=this.document.body.offsetHeight+"px";
        }
        else if(document.getElementById) {
            // ErnestoZ HACK: if you call scrollHeight TWICE, the second value is the real height of the iframe
            var scrollHeightWrong = this.document.body.scrollHeight;
            var scrollHeight = this.document.body.scrollHeight;
            alert(scrollHeightWrong);
            alert(scrollHeight);
            parent.document.getElementById(elementId).style.height = scrollHeight+"px";
        }
    }

OFC-CFC: Open Flash Chart - Coldfusion CFC Library

I just released version 1.0 of OFC-CFC on Google Code.

OFC-CFC is a Coldfusion CFC Library which produces JSON-data for Open Flash Chart version 2.0

The real power of Open Flash Chart is, you can update charts using JSON-data. Which means. update your charts using e.g. JQuery or Spry, without reloading a page.

So you can create charts like:

barchartAnimated

Please let me know if you have any questions or remarks.

ColdDoc, created by Mark Mandel, ROCKS!

In case you missed it, check out http://colddoc.riaforge.org/

Another piece of magic by Mark Mandel. It creates docs of your cfcs in JavaDoc-style and most important, it shows inherited methods too!

WHOIS your Daddy?

I was playing around with querying a whois server. Actually I didn't know it was that easy...

Here's the code:


<cffunction name="getWhoisData" access="public" returntype="string" hint="I return data from a whois server">
    <cfargument name="whoisQuery" type="string" required="true" hint="e.g. 'domain microsoft' or '?' to show whois server help-commands">
    <cfargument name="whoisServer" type="string" required="false" hint="e.g. whois.ripe.net. Default server is whois.internic.net">

    <cfscript>
        var whoisData = '';
        var whoisClient = createObject("java","org.apache.commons.net.WhoisClient");
        
        // use default whois server?
        if ( not isDefined("arguments.whoisServer") ){
            arguments.whoisServer = whoisClient.DEFAULT_HOST;
        }    
        
        try {
            whoisClient.connect(arguments.whoisServer);
            whoisData = whoisClient.query(arguments.whoisQuery);
            whoisClient.disconnect();
        } catch (Any exception) {
            whoisData = exception.message;
        }

        return whoisData;
    
</cfscript>
</cffunction>

Some examples:


<cfoutput>
    <h1>? [whois.internic.net]</h1>
    <pre>#getWhoisData('?')#</pre>    
    <h1>domain microsoft.com [whois.internic.net]</h1>
    <pre>#getWhoisData('domain microsoft.com')#</pre>
    <h1>=microsoft.com [whois.internic.net]</h1>
    <pre>#getWhoisData('=microsoft.com')#</pre>    
    <h1>registrar TUCOWS INC. [whois.internic.net]</h1>
    <pre>#getWhoisData('registrar TUCOWS INC.')#</pre>    
    <h1>-G -B 192.113.224.88 [whois.ripe.net]</h1>
    <pre>#getWhoisData('-G -B 192.113.224.88','whois.ripe.net')#</pre>    
</cfoutput>

JS Calendar - ColdBox plugin

I've created a ColdBox plugin which makes use of JS Calendar of Dynarch.

 

datepicker

 

LIVE SAMPLE (requested by Sana):

JS Calendar Sample

Usage:


<!--- input field 1 --->
<input type="text" id="startDate" name="startDate" value="" />
<img src="includes/img/icons/calendar.gif"
    id="startDate_trigger" style="cursor:pointer;" title="Date selector" />


<!--- input field 2 --->
<input type="text" id="endDate" name="endDate" value="" />
<img src="includes/img/icons/calendar.gif"
    id="endDate_trigger" style="cursor:pointer;" title="Date selector" />

    
<!--- Setup Calender --->
<cfset calendar = getPlugin("Calendar",1)>
<cfset calendar.setInputField('startDate','startDate_trigger','T1')>
<cfset calendar.setInputField('endDate','endDate_trigger')>

<cfoutput>#calendar.render()#</cfoutput>

Downloads:

JS Calendar (unzip and place it in your includes directory. It should look like this: {YOURAPP}/includes/jscalendar/..)

ColdBox Plugin (without JS Calendar!)

More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.9.004.