Sam Farmer

Growing up I never imagined I would play bass guitar for the Dave Matthews Band. And indeed it never happened.

But I have become passionate about making software.

ColdFusion Builder Extensions and forms: The easy way

July 1, 2010

In my previous post I chronicled my experiences building a ColdFusion Builder extension.  Raymond Camden, very politely, stated that some of my assertions where wrong.  Turns out Ray was right. I did some investigation and found that ColdFusion Builder extensions can in fact handle forms.  I didn't find a particularly good documentation of this so here is how to set up extensions to use html forms, javascript and html.  Even better it requires no parsing of XML to get form data.

ide_config.xml
 

<application>
    
<menucontributions>
<contribution target="projectview">
     <menu name="samEXT">
          <action name="Browser" handlerid="browser" showresponse="true" />
     </menu>
</contribution>
</menucontributions>
 
<handlers>
     <handler id="browser" type="cfm" filename="browser/index.cfm" />
</handlers>
 
</application>

Nothing special or different in this file.  In the above code we add a menu item and have the action point to an index.cfm file.

index.cfm

<cfsetting showdebugoutput="false" >
<cfheader name="Content-Type" value="text/xml">
<response showresponse="true">
     <ide url="http://play/extensions/SamExt/handlers/browser/aform.cfm" >
          <dialog width="500" height="600" />
     </ide>
</response>

This file will be called when the menu item is clicked on.  The key line is the ide tag which points to a URL.  You can see this called aform.cfm and doing this method breaks out of the Eclipse controls and into the default browser for Eclipse (or your system...I'm not sure which).

aform.cfm

<cfsetting showdebugoutput="false" >
<cfform method="post" action="formresults.cfm">
     <label>Text</label><br>
     <cfinput type="text" size="30" name="text" id="text" required="true" message="Give me some text, baby!">
     <br><br>
     <label>Date</label><br>
     <cfinput type="datefield" size="30" name="date" id="date" required="true" message="Come on...pick a date.">
     <br><br>
     <cfinput type="submit" name="sub" value="Show me">
</cfform>

Love or loath cfform, I used it above to illustrate that JavaScript works. This makes a form in the extension:

It posts to formresults.cfm which simply dumps out the form results as seen below:

formresults.cfm

<cfdump var="#form#">

 


No Comments

Some comments have been lost over the years due to moving hosts.

More


More blog entries that I have written.

Code coloring by PRISM.