Monday, November 5, 2012

CFWheels FindAll using Aliases Note

So, I typically use SQL Servers MMC (Management console) to create complex queries and visualize relationships between tables, since it has such a fantastic GUI for doing this.

 I have a query that brings in a second(and third) table via wheels include="secondModel(thirdModel)", and counts up how many rows are in the third table... long story short.. there is a SUPER EXCELLENT feature of wheels where it allows you to use the DATABASE column names and table names.. effectively giving you control again for this case... you just have to:

 http://cfwheels.org/docs/1-1/function/findall 

SELECT: 
Determines how the SELECT clause for the query used to return data will look. You can pass in a list of the properties (which map to columns) that you want returned from your table(s). If you don't set this argument at all, Wheels will select all properties from your table(s). If you specify a table name (e.g. users.email) or alias a column (e.g. fn AS firstName) in the list, then the entire list will be passed through unchanged and used in the SELECT clause of the query. By default, all column names in tables JOINed via the include argument will be prepended with the singular version of the included table name.

So, if you have a complicated select statement, you don't have to try and figure out what wheels has mapped your column names to now that there are multiple tables involved, you can just use their actual names. I've being using wheels for quite a while now, and never knew that it had this behaviour. No wonder I got frustrated with wheels when doing complex joins and aliases... it was switching to un-wheelsy mode.. and not telling me!!

Caveat: I really like cfwheels' built in ORM. I enjoy not needing using sql servers' table and column names, along with the table prefixes in my queries. But, in some cases...you know them.. the cases where you threaten wheels that you're going to break out a <CFQUERY> tag and just paste in the answer... its nice to just be able to go half-way.

Thursday, October 25, 2012

Git-er done.

I'm updating my world into GIT this week. Our version control system was SVN (via VisualSVNServer), but branching and tagging were always ominous.

- GitHub for windows. http://windows.github.com/

- EGit for Eclipse. The setup docs are at: http://wiki.eclipse.org/EGit/User_Guide#Setting_up_the_Home_Directory_on_Windows

- Git Issue Tracker mobile (Ipad) http://mobile.github.com/


Thursday, October 4, 2012

Railo Websockets Gateway Conflict with CFWheels

So, apparently, the Railo Websockets Gateway Extension conflicts with CFWheels.

The doc to get you started is at: http://wiki.getrailo.org/wiki/Extensions:WebSockets_Gateway#Sample_Apps

Which was giving me the error: "Gateway:my_websocket_gateway","key [WHEELS] doesn't exist in struct (keys:applicationname)"

Documented by another user here: http://code.google.com/p/cfwheels/issues/detail?id=860

The fix I found is similar, although less dramatic than "commenting out the $abortInvalidRequest();in both the events/onapplictionstart.cfm and also the events/onrequeststart.cfm allowed me to at get passed the point of the gateway not starting up."

I looked into the cfwheels code for  /wheels/global/internal.cfm --> $abortInvalidRequest  and, in my working copy, I've changed line 261 to not cause a 404 when the file in the calling path is from WebSocket.cfc, leaving wheels core functionality in place.

if ( (ListLen(callingPath, "/") GT ListLen(applicationPath, "/") || GetFileFromPath(callingPath) == "root.cfm" ) && ( GetFileFromPath(callingPath) != "WebSocket.cfc" )  )


Now.. on to WebSockets for Railo... I hope its more straight forward than having to compile java classes for Red5 ;-)

Friday, August 10, 2012

Coldfusion Session Tracker Object

I just discovered a fantastic blog post mentionning that Coldfusion (& Railo) have a java object that keeps track of sessions (that you can instantiate).. no more trying to count active sessions.


<cfset sessionTracker = createObject("java","coldfusion.runtime.SessionTracker")>
<cfdump var="#sessionTracker#">


Tuesday, July 10, 2012

CFWheels 1.1.8 Url Rewriting

CFWheels 1.1.8, IIS 7.5 on Win 7x64, Apache Tomcat running Railo 3.3

It seems url rewriting has been a tough nut to crack... and of course, now that I've figured it out... not so much :-)

- Add rewrite module to IIS 7.5 (Reboot your server.. I couldn't get the Rewrite module to show in the IIS control panel.)
- Enable rewriting by un-commenting out lines in your web.config that comes with cfwheels (This makes the rule appear in the IIS rewrite panel as a rule btw)

-  Review guide about rewrite configuration in IIS Console directly (nice for testing & understanding what's going on)
- Enable logging for starters (helpful) Hunt around in here for the log: C:\inetpub\logs\LogFiles\
- In tomcat's \tomcat\conf\web.xml 

Around line 429 "<!-- The mapping for the Railo servlet -->"   make sure this is NOT commented out:

<servlet-mapping>
    <servlet-name>GlobalCFMLServlet</servlet-name>
    <url-pattern>/rewrite.cfm/*</url-pattern>
</servlet-mapping>

Friday, July 6, 2012

Railo 4.0

Is it christmas? Is it my birthday? Nope... Railo 4.0 is in Beta, and the long list of new tweaks and features they've added are super exciting...and they've 'fixed' some things I had just learned to work around (such as the UPPERCASING of struct keys when the dot notation was used)

The most important of which, for me is the long awaited fix for URL Rewriting!!! I've known for a while now that the cgi.path_info param needed for url rewriting to work got lost between IIS and Railos connector. Railo 4 Beta Release

Read all about the new features: Railo 4 Beta Release Features

OWASP

OWASP Intro to XSS Attacks:


Thursday, June 7, 2012

Railo 3.3 on Jelastic.. socks officially blown off!

Wow. A one-click .war distribution on scalable hosting... this could be a game changer... Unfortunately:

- Jelastic doesn't use MS-SQL.. which means no management console. An alternative might be the fact that mySQL does have a GUI via workbench
- Jelastic uses Maven.. and has no support for Checkout only.. which means old-school ftp based updates for your site, instead of an svn-update to a specific version Railo In The Cloud  I'll let you know when they take my "good idea" and implement it :-)


Turning an email address into an image using ColdFusion ( Railo 3.3 )


I've come across the need to be able to render text in a browser (specifically, in this case an email address) that is not easily robot-readable, and is painless to show inline in the browser.

<cfset request.newImage = imageNew("",250,15,"rgb","white")>
 <cfset request.textRow1="email@email.com">
 <cfset attr = { font="SansSerif.plain", size="12", style="bold"}>
 <cfset imageSetDrawingColor(request.newImage,"black")>
 <cfset imageDrawText(request.newImage, request.textRow1, 0, 10, attr)>

 <cfimage action = "writeToBrowser"
   source = "#request.newImage#"  
   format="png"
isBase64="no"
 >

Thanks to: http://www.bjw.co.nz/developer/coldfusion/94-turning-an-email-address-into-an-image-using-coldfusion

Wednesday, May 23, 2012

Here we go again. Railo Setup Apache-Tomcat with IIS7.5 on Win7x64

My notes from a recent IIS7.5 setup on Win7x64 for Railo 3.3.1.000 Final (which uses Apache-Tomcat)

Started with a blank installation of IIS, by adding it as a feature in Windows 7x64bit

Using my already installed and running Railo 3.2 on Apache:

Edited C:\railoserver\tomcat\conf\server.xml. I changed line 55 back to default port 8888 (Had mine set to 80 previously)

<Connector port="8888" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

Restarted Apache.

For some reason, on my workstation the railoserver's connector hadn't been modified by the vivio installer to have the correct path variable "@@installdir@@" replaced with a static value.. (Which is required!)

Edited C:\railoserver\connector\iis7connect.bat and iis7remove.bat
Replaced "@@installdir@@" with "C:\railoserver" 
Ran iis7connect.bat
Created website in IIS, added jakarta as a virtual directory, pointing to C:\railoserver\connector as usual.

Then... Nuts... "Insert picture of ambiguous error here"


Eventually figured out that it wasn't lying to me.. there was a problem with the isapiFilterModule..

Edited: C:\railoserver\connector\isapi_redirect-1.2.30.properties
Replaced "@@installdir@@" with "C:\railoserver" 

(This workstation must have installed strangely... I thought this @@ stuff was supposed to be changed by the installer.. anyways...)

Restarted IIS.

Victory!!

Other Notes:

Read through: http://wiki.getrailo.org/wiki/Server_2008_R2_IIS_7.5_with_Tomcat_and_Plesk

Which mentions about 500.19  .. I only seem to get this error when attempting to setup a webroot outside of IIS   C:\inetpub\wwwroot    and I specifically get 0x8007000d   (Notice the d at the end... which microsoft says is an web.config error.. which it isn't in my case.. removing web.config just changes the error to 500... so I have a permissions issue in this case... great...)


I incorrectly thought it was something to do with web.config attempting to override a setting that had overrides disabled... (It wasn't) : http://learn.iis.net/page.aspx/376/delegating-configuration-to-webconfig-files/


This was actually caused by attempting to enable the rewrite module, when the rewrite module was not installed: http://www.microsoft.com/web/gallery/install.aspx?appid=urlrewrite2



Saturday, May 19, 2012

RESTful resources

Learning about REST. http://tomayko.com/writings/rest-to-my-wife