November 21, 2008

Pages


Search Site


Topics



Archives

Tweets

Entries Tagged as 'Scorpio'

My onMissingTemplate article is up on dzone!

March 13 2008 by Adam
I recently sat down to put together a blog post covering how to "bridge the gap" between a 404 and onMissingTemplate (because a .cfm file has to be requested before the web server hands the request off to ColdFusion), and I thought that it would make a great article for dzone, so I submitted it there instead. If you're intrigued by onMissingTemplate, but frustrated that it doesn't work for just a requested folder, go check it out!

Posted in ColdFusion | ColdFusion 8 | Scorpio |

AJAX in ColdFusion 8: Don't overthink it!

July 17 2007 by Adam
For CFMenuCal, I'm planning on using AJAX to display a "settings" type window, which will allow you to edit your meal data, allowable proximities, and other settings. To teach myself the basics of CFAjaxProxy and get a better idea of how to write my components to that end, I made a simple page that dumps the session scope, and has a form with a textbox and submit button that should – in theory – make the AJAX call to my test component, which will then update the session scope. I know this sounds pretty simple, and in actuality, it is. But I spent at least a couple of hours on Saturday reading up on JSON, and thinking about how I'll need to implement it. I was thinking I would need to serialize my data on the client side, and then use DeserializeJSON() in my component to turn the JSON string into CF variables. As it turns out – that was wasted time. It's all done implicitly for you. So first, let's build our component:

<cfcomponent name="AjaxTest" hint="Performs some proof of concept AJAX functionality for CFMenuCal.">       <cffunction name="updateSession" access="remote" output="false" returntype="Boolean">         <cfargument name="data" type="any" required="true">         <cftry>             <cfset session.data = arguments.data>             <cfreturn true>             <cfcatch type="any">                 <!— log the error via cfmail or cffile —>                 <cfreturn false>             </cfcatch>         </cftry>     </cffunction>   </cfcomponent>

Notice that the I set the ACCESS of the function to REMOTE. This pretty frequently gets me (I commonly use PUBLIC), and I spend too much time trying to figure out why I'm getting "method X doesn't have any properties" JavaScript errors. So now that we have our component, we need a page that uses it. Enter test.cfm:

<cfajaxproxy cfc="com.AjaxTest">   <cfdump var="#session#" label="Session Scope">   <form method="post" name="fooForm">     <input type="text" name="bar" size="30" />     <input type="button" onClick="sessionize(this.form.bar.value);" value="Save" /> </form>   <script type="text/javascript" language="javascript">     sessionize = function(data){         var updater = new com.AjaxTest();         var myObj = {};           myObj.numberValue = 42;         myObj.stringValue = "hello, world!";         myObj.userValue = data;           var success = updater.updateSession(myObj);           if (success == "true" || success == true){             alert('Success! Refreshing the page to update dump…');             document.location.href = document.location.href;         }else{             alert('An error occurred. Check the log for details…');         }     } </script>

The above assumes the component is named AjaxTest and resides either in a subdirectory named "com" of the current directory, or of the root folder. Running it should produce a cfdump that looks something like this:

CFDump

The moral of the story is: Don't overthink it! The ColdFusion 8 team over at Adobe has made this too easy.

Posted in AJAX | CFMenuCal | ColdFusion | Scorpio |

Can it be? It's finally here?

June 23 2007 by Adam
CFMenuCal α1 is, dare I say, ready for you to play with! Considering that this is an alpha release, there is no way to modify user data (aka meals, settings) on-page. You'll need to edit config.cfm to change those things. Of course, this isn't a problem for you, because you're taking advantage of the ColdFusion 8 public beta, right? I would love to get some feedback from anyone who plays with it. What do you like or dislike about it? What do you think should work differently? Feature requests, bug reports… bring it on!

Posted in CFMenuCal | My projects | Scorpio |

ColdFusion8 doesn't create Client Variable tables for MySQL

June 21 2007 by Adam
…and potentially other database types. Tonight I installed the latest CF8 beta on my home file/web server so that I can continue development and tinkering even in the event of a catastrophe. The server is running Ubuntu and MySQL, which to be honest, means this is the first time I've had to store client variables in a MySQL database. In the past, MS SQL Server has always at least been an option, and I never bothered before. In the event that you might need the code to create these tables, because I did, you can find it here. I gather that this is not a new development (the page I linked indicates that these instructions are for MX), but I personally would have thought that now that MySQL is an officially supported DBMS, they would have implemented such a remedial feature. If you can't be bothered to click through, here's the code:

<cfquery datasource="mydatasource">   CREATE TABLE cdata (     cfid varchar(64) NOT NULL default '',     app varchar(64) NOT NULL default '',     data longtext NOT NULL,     PRIMARY KEY (cfid,app)   ); </cfquery> <cfquery datasource="mydatasource">   CREATE TABLE cglobal (     cfid varchar(64) NOT NULL default '',     data longtext NOT NULL,     lvisit timestamp(14) NOT NULL,     KEY cfid (cfid),     KEY lvisit (lvisit)   ); </cfquery>

Posted in ColdFusion | Scorpio |

CFMenuCal: Configuration!

June 07 2007 by Adam
I just couldn't resist playing with all of the sexy AJAX tags and CFWindow. I couldn't. I can't play with new syntaxes and not the new tags. So I put aside working on side-dish proximity checking and instead worked on this beautiful screen:

CFMenuCal: Config Screen
Click to enlarge

There is plenty of functionality in there that doesn't work, or works incorrectly. But the skeleton is there, and you can get an idea of where I'm headed with it. The code has been committed to the repository, but the demo has not been updated. So if you're eager to see it up close and personal, check it out! (Literally!) I promise I will work on side dish proximity next, so that I can go ahead and call it an alpha release. Promise.

Posted in AJAX | CFMenuCal | My projects | Scorpio |