919 - 926 - 9847

Bind CFGrid updates to a form field

I searched for a fairly good amount of time before figuring this out.  The background is this.

I don't usually have much use for CFGrid, at least not since the CF 4.x days.  That being said, I found myself in need of it this week for a project which I've been assigned to.  The grid was pulling data back correctly, but what it really needed to do was refresh when you select value XX from a select box.  The answer turned out to be pretty simple.  First, the form.

 


<html>
<head><title>test me</title></head>
<body>

<!--- You MUST use a CFFORM here --->
<cfform name="myProds" action="" method="post">

<!--- Our select box --->
<select name="product" id="product" class="datasectiontextlong">
    <option value="0">--Select a product--</option>
    <option value="1">Product 1</option>
    <option value="2">Product 2</option>
</select>

<!--- Our grid (notice the select box value here) --->
<cfgrid format="html"
    name="products"
    pagesize="7"
    height="200"
    width="550"
    bind="cfc:myCFC.getProds({myProds:product},{cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})"
>

    <cfgridcolumn name="ID"/>
    <cfgridcolumn name="display" header="Your Choice">
</cfgrid>

</cfform>
</body>
</html>

And the CFC

 


<cfcomponent name="myCFC" displayname="You can't touch this" output="false" >
    <!--- We use some dummy data in this instance --->
    <cffunction name="getProds" access="remote" returntype="struct">
    <cfargument name="productID" required="true" type="numeric" />
        <cfargument name="page" type="numeric" required="yes">
<cfargument name="pageSize" type="numeric" required="yes">
<cfargument name="gridsortcolumn" type="string" required="no" default="">
<cfargument name="gridsortdir" type="string" required="no" default="">
        
        <cfscript>
    var selectQuery = QueryNew("ID,display");
            var tmp=queryaddrow(selectQuery,2);
            tmp=querysetcell(selectQuery,'ID','1',1);
            tmp=querysetcell(selectQuery,'ID','2',2);
            tmp=querysetcell(selectQuery,'display','You chose wisely',1);
            tmp=querysetcell(selectQuery,'display','You chose poorly',2);
        
</cfscript>
        <cfquery name="returnQuery" dbtype="query">
            select ID,display
            from selectQuery
            where ID = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.productID#">
        </cfquery>
<cfreturn QueryConvertForGrid(returnQuery,
arguments.page,
arguments.pageSize)>

    </cffunction>
    
</cfcomponent>

The missing piece (for me) was that first bit in the CFGrid CFC call.  myProds.product.  If you tell the grid to pass this as a variable into the CFC function, you can then pass that into your select statement.  I presume this holds true for any form field and not just select boxes. 

ColdFusion Builder Trial: subclipse issues

Part 2 for getting CF Builder 2 to work for my needs.

I use Subclipse for almost all my projects, as pretty much everything is hosted on my Subversion server.  I've never had issues installing Subclipse before so this was new to me.  I ran into the same exact problem as found here http://mineer.blogspot.com/2010/01/coldfusion-builder-beta-3-and-subclipse.html (Subclipse won't all you to click the license agreement), but again no resolution that I could find.

This was much simpler to resolve.  It looks like some dependencies aren't being met for Subclipse.  I added the site for http://download.eclipse.org/releases/helios to the list of software update providers (Help -> Install New Software).  I grabbed everything from the collaboration packages, but you can probably get away with just the missing ones.  The Subclipse install tells you which these are, but to err on the safe side, I grabbed everything.

After a workspace restart Subclipse installed just fine.  I'm now all set and ready to test everything builder has to offer.

Part 2 for getting CF Builder 2 to work for my needs.

I use Subclipse for almost all my projects, as pretty much everything is hosted on my Subversion server.  I've never had issues installing Subclipse before so this was new to me.  I ran into the same exact problem as found here http://mineer.blogspot.com/2010/01/coldfusion-builder-beta-3-and-subclipse.html, but again no resolution that I could find.

This was much simpler to resolve. 

Part 2 for getting CF Builder 2 to work for my needs.

I use Subclipse for almost all my projects, as pretty much everything is hosted on my Subversion server.  I've never had issues installing Subclipse before so this was new to me.  I ran into the same exact problem as found here http://mineer.blogspot.com/2010/01/coldfusion-builder-beta-3-and-subclipse.html, but again no resolution that I could find.

This was much simpler to resolve.  It looks like some dependencies aren't being met for Subclipse.  I added the site for http://download.eclipse.org/releases/helios to the list of software update providers (Help -> Install New Software).  I grabbed everything from the collaboration packages, but you can probably get away with just the missing ones.  The Subclipse install tells you which these are, but to err on the safe side, I grabbed everything.

After a workspace restart Subclipse installed just fine.  I'm now all set and ready to test everything builder has to offer.

It looks like some dependencies aren't being met for Subclipse.  I added the site for http://download.eclipse.org/releases/helios to the list of software update providers (Help -> Install New Software).  I grabbed everything from the collaboration packages, but you can probably get away with just the missing ones.  The Subclipse install tells you which these are, but to err on the safe side, I grabbed everything.

After a workspace restart Subclipse installed just fine.  I'm now all set and ready to test everything builder has to offer.

ColdFusion Builder Trial: connecting up RDS

My it's been awhile hasn't it?  New job, old job, and other jobs between have been keeping me more busy than I can even relate.

Just for kicks I've decided to give the CFBuilder trial a whirl.  It's being evaluated by the office, and we were having some issues connecting it up to RDS on our local machines.  This lead to the some exploring to find out where the problem lies.

First I went out and grabbed CF Builder 2.  http://www.adobe.com/products/coldfusion-builder.html.  After it got done installing I tried setting up an RDS interface to my local CF 9 install.  And, whoops, hit upon the same error my co-worker saw.  It's fairly unhelpful, mostly just a null java pointer exception.  It lead me to this page on the Adobe forums http://forums.adobe.com/message/4234561, but offered no real resolution.

It dawned on me that RDS was likely not enabled during the installation of CF 9 on my current laptop.  I did the following to address the issue with RDS not connecting (note, some steps may not be necessary, such as adding a new RDS user, but it didn't work for me without one).

  • Open your ColdFusion administrator interface and under the security left hand navigation set both administrator and RDS to use Separate user name and password authentication (allows multiple users) .
  • Create a new RDS user and give them every authority under the sun (eh, it's local).
  • Open up the ColdFusion instance web.xml, and this will vary depending on how you installed ColdFusion.  Mine was found in C:\ColdFusion9\wwwroot\WEB-INF.  The multi-server install will be in a path similar to <jrun-install>\servers\<instance>\cfusion-ear\cfusion-war\WEB-INF.
  • Do a search on RDS.  There should be two separate <servlet> mappings which need to be uncommented.  Uncomment each block.
  • Restart ColdFusion.
  • In CF Builder add a new server for RDS (or edit an existing one).  It was a tab in the bottom pane of the program for my installation.
    • Server Name:  This can be any value, it's just used the purpose of display
    • Application Server: I'll presume you're using JRun
    • Host Name: localhost
    • WebServer Port: 8500 for standard install, consult jrun.xml if you're using multi-server
    • RDS User Name: Name used in the previous step
    • RDS Password: Again, from a previous step
    • Click Next
    • Server Home: Mine was C:\ColdFusion9, not sure where this is on multi-server
    • Document Root: It defaults to wwwroot for the ColdFusion9 folder, and I don't see a reason to change it.
    • Click Finish

After the above, both my co-worker and I were able to successfully connect to our RDS services.

Win 2008 64bit + Adobe CF 64bit + Apache

Sometime last year, when we migrated our Win 2003 + IIS servers over to 2008 + Apache, I ran into an issue.  It only happens on 64bit Windows (and 2008 at that), and it just slipped my mind to blog something on it.  It came up again on a list I follow, so it appears to be a good time to blog on it.  I also got transitioned away from the server team over to the development team and the desire to post about it also went the ladder of "things I need to do".

The error message is "The application has failed to start because its side-by-side configuration is incorrec".  I noticed that the machines I DIDN'T have an issue with already had .NET 3.5.x on them.  The machines without it, this error cropped up.  The solution (for me) and for the poster on the board was to simply install .NET on the server.  After that, no more issues!  Another suggestion was to install the VC 2008 components from Microsofts site.  I've yet to try that, but it may work.

The other issue I ran into is after getting everything all hunky dory and working, the Apache connector just downright fails as soon as the 9.0.1 patch was installed.  The solution there was to run through the wsconfig connectors immediately after installing ACF, THEN do the upgrading of the various servers and instances.

How to configure a kick ass development setup - day 4

On our plate today, we'll be installing Apache.  I'm using the 2.2.x branch.

  • Go and grab your .msi, I'd recommend the one with OpenSSL included.  http://httpd.apache.org/download.cgi#apache22
  • Install Apache to c:\cf_dev\apache.  You'll need to choose "custom install" to change the directory. The other values can be left at default.
  • Get CF9 hooked up to Apache, Start-> All Programs-> Adobe-> CF9 xxxx-> Web Server Configuration Tool
  • Click Add... to create a new connector
  • Choose the CFusion instance and select Apache as your web server.  You'll need to pick out the configuration directory (c:\cf_dev\apache\conf) and the binary object (c:\cf_dev\apache\bin\httpd.exe) and check "install CF9 services".
  • Edit c:\cf_dev\apache\conf\httpd.conf and add at the bottom (the include pulls in any files we add to dev folder):
    #Turn on virtualhosts
    NameVirtualHost *:80
    NameVirtualHost *:443

    Include c:/cf_dev/apache/conf/dev/*.conf

    <Files ~ ".hbmxml$">
    Order allow,deny
    Deny from all
    </Files>
  • Find DirectoryIndex in the httpd.conf file, and add index.cfm to it.
  • Create a new site vhost file, we'll start with site1 (from back on day 1).  Create it as c:\cf_dev\apache\conf\dev\site1.conf
  • Fill it like so:
    #site1
    <VirtualHost *:80>
    <Directory "C:\cf_dev\projects\site1">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
    </Directory>

    alias /CFIDE C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\CFIDE
    alias /cfide C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\CFIDE

     # JRun Settings
    <IfModule mod_jrun22.c>
        JRunConfig Verbose false
        JRunConfig Apialloc false
        JRunConfig Ignoresuffixmap false
        JRunConfig Serverstore "C:/JRun4/lib/wsconfig/1/jrunserver.store"
        JRunConfig Bootstrap 127.0.0.1:51020
        AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc .cfr .cfswf
    </IfModule>   

     DocumentRoot "C:\cf_dev\projects\site1"
     ServerName site1.local
     ServerAdmin contact@localhost
    </VirtualHost>
  • Note, you should now remove all but LoadModule jrun_module "C:/JRun4/lib/wsconfig/1/mod_jrun22.so" from c:\cf_dev\apache\conf\httpd.conf.  This will allow us to use multiple J2EE engines under the same apache config.
  • Edit http.conf, and uncomment:
    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
  • Create a Railo based site for Site2 (follow the steps found on day one to first create the site2 project), fill the c:\cf_dev\apache\conf\dev\site2.conf with (we use proxypass to hand of CFM requests):
    #site2
    <VirtualHost *:80>
    <Directory "C:/cf_dev/projects/site2">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
    </Directory>

    <Proxy *>
                Allow from 127.0.0.1
        </Proxy>

    ProxyPreserveHost On
    ProxyPassMatch  ^/(.+\.cf[cm])(/.*)?$  ajp://localhost:8009/$1$2

     DocumentRoot "C:/cf_dev/projects/site"
     ServerName site2.local
     ServerAdmin contact@localhost
    </VirtualHost>
  • To make Tomcat aware of server, we need to add this just before the </engine> tag at the end of c:\cf_dev\tomcat6\conf\server.xml.  It seems like duplication, but it just MUST be done:
    <Host name="site2.local" appBase="webapps" unpackWARs="false" autoDeploy="false" xmlValidation="false" xmlNamespaceAware="false">
              <Context path="" docBase="C:/cf_dev/projects/site2" />
        </Host>
  • Edit your hosts file (mine is at C:\Windows\System32\drivers\etc\hosts) to locally route our requests to the correct place.
    127.0.0.1 site1.local
    127.0.0.1 site2.local

How to configure a kick ass development setup - day 2

The next step on our journey is to install Adobe ColdFusion 9.x in the multi-server configuration. 

  • Download the installer from https://www.adobe.com/cfusion/tdrc/index.cfm?product=coldfusion.  You WILL need an Adobe ID, but it's free to sign up.  If it's not version 9.01, be sure to grab that update as well.
  • If you don't already have it, you'll need to install the .NET framework (required for the install to complete). http://www.microsoft.com/download/en/confirmation.aspx?id=22
  • As mentioned previously, we want to use the multiserver install option after running the .exe, and make sure to configure internal web server (we'll address the connector later).  Also, the developer edition will be fine for our purposes.  The path I chose was c:\cf_dev\jrun.  Install whatever options you want, but keep in mind they're a pain to get in after the fact.
  • If you need to run the 901 (or other) updater, you need to stop services before hand.  The two main ones are Macromedia JRun Admin and Macromedia JRun CFusion need to be stopped.  There's also going to be several "ColdFusion" related services that need to be stopped.  You can go ahead and set the Admin instance of ColdFusion to manual, as we'll only use that if we want to add a new CF instance.

Optional

  • If you're feeling adventurous, grab a CF8,7,6 installer.  Choose the last option of a ColdFusion EAR/WAR (EAR specifically).  Choose the install location to be c:\cf_dev\jrun4\servers\<someinstance>.
  • Manually open your unzipping program (winzip works), extract c:\cf_dev\jrun4\servers\<someinstance>\cfusion-ear out to the folder cfusion-ear.  Go into cfusion-ear and extract cfusion-war out to cfusion-war and META-INF.
  • The XML file in META-INF will be wrong, you need to change it so it looks like:
    <code>
    <?xml version="1.0" encoding="ISO-8859-1"?>

    <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">

    <application>

      <display-name>cfusion-ear</display-name>

        <module>
          <web>
            <web-uri>cfusion-war</web-uri>
            <context-root>/</context-root>
          </web>
        </module>
    </application>
    </code>
  • Start that Admin instance back up, and log into it at localhost:8000, and use the user "admin" and password <whatever you set the default cf password at>.
  • Click the "create a new server" link.  The server name MUST match the folder name you created in step 1.  Ports and such can be left the same.
  • Create a service for this bugger, bring up a command prompt and run c:\cf_dev\jrun4\bin\jrunsvc -install <foldername> <foldername> "Macromedia JRun <foldername> Server" "Macromedia JRun <foldername> Server" -config <path to jvm.config if you want different JVM settings, which you'll need for older CF versions, JVMs are not going to be compatible>
  • Start the service, and be happy.

Odd FarCry 3.1 problem on CF 9

By way of the grapevine, I was hooked up with a client in DC that had upgraded their server from CFMX 7.x to CF 9.x.  There were some issues with built-in functions in the older FarCry code, but that was corrected by the team at Myriad.  The front end was working fine, but the FarCry admin was giving a blank page.

In the past, I've seen this with older versions of Railo and built-in functions clashing, and that was the assumption I went with.  Alas, that turned out to not be it.  However, there were clues in the error logs of the CFadmin.  Essentially, it was going into an odd loop looking for a file called "apps.cfm".  Ahhhh, that file.  It's been a while, but that file controls how the admin finds projects against the URL you're coming in from.

Once I put a call to <cfset stApps['site.local'] = 'farcry_site'>, the FarCry admin started working on my local test.  Rock on! 

It was a fun little adventure for a weekend.  I thought, should anyone else run into this, it'd be nice to document it for future reference.

You do development on Apache+Tomcat+Railo+Adobe CF+Resin+etc

So let's say you support multiple customers, and a mix of Adobe ColdFusion, Railo, and multitudes of J2EE servers.  You want to remain true to the environment you're developing against, so you end up installing all the pieces to make that happen.  At one point, I had ACF 6.x - 8.x installed on my laptop, but for now I just need ACF 9.x and Railo+Resin or Tomcat.

I like to pipe everything through Apache.  I realize that most modern J2EE engines can handle tons of traffic, most still cannot (easily) match the power of mod_rewrite and Apache.

I won't be detailing how you install ACF, or Apache, etc in this post.  I do plan on doing so at some point down the line, but it won't be this post.

Firstly, in your httpd.conf, we set up our Resin/ACF DLLs.


LoadModule jrun_module "<JRUNpath>/lib/wsconfig/1/mod_jrun22.so"
LoadModule caucho_module "<railopath>/win32/apache-2.2/mod_caucho.dll"

Next, make a directory to hold your Apache virtual hosts configs and add this nifty line to your httpd.conf.  Note, this is the windows syntax.  You don't need the *.conf in *nix for whatever reason.


Include <apachepath>/conf/mysites/*.conf

Make a site1.conf in the mysites folder, and this is what it would look like for ACF.


<VirtualHost *:80>
<Directory "<projectpath>\site1">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

alias /CFIDE C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\CFIDE
alias /cfide C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\CFIDE

# JRun Settings
<IfModule mod_jrun22.c>
JRunConfig Verbose false
JRunConfig Apialloc false
JRunConfig Ignoresuffixmap false
JRunConfig Serverstore "C:/JRun4/lib/wsconfig/1/jrunserver.store"
JRunConfig Bootstrap 127.0.0.1:51020
AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc .cfr .cfswf
</IfModule>



DocumentRoot "<projectpath>\site1"
ServerName site1.local
ServerAdmin contact@localhost
ErrorLog <projectpath>\site1\apache_logs\error.log
TransferLog <projectpath>\site1\apache_logs\access.log
</VirtualHost>

For Resin+Railo, it'd look like this for site2.conf


<VirtualHost *:80>
<Directory "<projectpath>\site2">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

ResinConfigServer localhost 6800
<Location /caucho-status>
SetHandler caucho-status
</Location>



DocumentRoot "<projectpath>\site2"
ServerName site2.local
ServerAdmin contact@localhost
ErrorLog <projectpath>\site2\apache_logs\error.log
TransferLog <projectpath>\site2\apache_logs\access.log
</VirtualHost>

For our last example, site3.conf, we'll use Tomcat+Railo


<VirtualHost *:80>
<Directory "<projectpath>\site3">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

<Proxy *>
Allow from 127.0.0.1
</Proxy>

ProxyPreserveHost On
ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://localhost:8009/$1$2

DocumentRoot "<projectpath>\site3"
ServerName site3.local
ServerAdmin contact@localhost
ErrorLog <projectpath>\site3\apache_logs\error.log
TransferLog <projectpath>\site3\apache_logs\access.log
</VirtualHost>

So how did you get started in ColdFusion?

My journey to ColdFusion stared in 2001. I was working at getting a BA in order to escape the inability to break into the "computer" world. As part of my internship for school, I got to choose where I got the privilege of paying $300 to work for free (yay education system), and that place was EXTOL International Inc. in Pottsville, PA. My in-laws worked as AS400 developers there (still do), and it seemed like a great place to start out. At any rate, it was a "foot in the door" situation that I couldn't pass up, and just 15 minutes up the road.

I started work under Mark Dempshey, the then current product manager and webmaster, and was given the task of learning about ColdFusion and the network in general. So for 40 hours a week, which was double the requirement, I spent 9 weeks working full time (for free) learning the ropes in the computer world, as well as my 3-11 paid job. It was a challenge, but well worth it as I was able to translate that internship into a paid position.

We started out on ColdFusion 4.01 and Access (good lord, why??), and when I left in 2006 we had moved to ColdFusion MX 6.1 against MSSQL. We grew from a home grown, gnarly CMS, to the FarCry CMS. I've discovered that I have no real ambition to EVER work under the NJ/NY mind-set again (you didn't read my mind and make that webform already?? We sent it to print!! We'll send you a graphic soon). Sadly they've since moved to a hosted solution that's either ASP or PHP, but that's just the way the ball bounces sometimes. There really wasn't anywhere to go "up", so I had to leave PA in order find better prospects. Still, they kept me on for 9 months as a consultant. I miss the area, but the opportunities presented in the Triangle area should keep me covered for a good number of years to come.

Where would I be without ColdFusion? Probably as a java/php/asp developer. I personally like being a CF dev and wouldn't change it for the world.

Whoops, error in that last post

I modified a block of code to check that "attributes.return" is true as well as exists.

After the code block (don't forget the if)


<!--- Return to the objectadmin --->
<cfif structKeyExists(attributes, "Return") AND attributes.return EQ 'true'>
<cfset attributes.exit = true />
<cfset stLocal.onExitProcess = structNew() />
<cfset stLocal.onExitProcess.Type = "Return" />
<cfset stLocal.onExitProcess.Content = "" />
</cfif>