Viewing by month: May 2009

May 27 2009

Setting up Google Mail in Railo

Another one for my notes that may help others. Here are the settings to uses Google mail Server for send emails from Railo.

SMTP: smtp.gmail.com
Username: email@gmail.com
Password: *********
Port: 587
TLS: checked
SSL: not checked

Posted by AJ Mercer at 7:45 PM - Categories: Railo

May 27 2009

Railo Express with Virtual Hosts

I wanted to play around with Railo's Extentions without too much messing around. So I thought I would use Railo Express, but I wanted a web site per application, so they could run from the web root. After a bit of Googling (with google cache to the rescure for www.railo-technologies.com/en/index.cfm?treeID=211) I found out how to get this working. This blog is mostly for my personal records, but if it helps others that is great too.

In /contexts directory you will see railo.xml. Make a copy of this file, eg railo-mangoblog.xml, and then edit it.
Find the following
    <Set name="resourceBase">
        <SystemProperty name="jetty.home" default="."/>/webroot/
    </Set>
and change webroot to a new name, eg webroot-mangoblog

In the same file, uncomment the virtual hosts section and add you domain. eg
  <Set name="virtualHosts">
    <Array type="String">
      <Item>mangoblog.railo.org</Item>
    </Array>
  </Set>

Save this file.

Next create the directory you just defined in the same directory as webroot.

(Re)Start Railo using the BAT file(s). You should see a WEB-INF directory being created for you. You can now administor you site for that domain, eg http://mangoblog.railo.org/railo-context/admin/index.cfm

Posted by AJ Mercer at 7:19 PM - Categories: Railo

May 14 2009

Population PDF Forms with ColdFusion 8

Now that Adobe owns ColdFusion, a lot of PDF functionality has been added to CF8. Amongst that is the ability to populate PDF Forms. This means you can pre-populate forms for clients / members - how many times have you had to fill out a form and think to yourself, 'they already know this stuff!!'

The client / member can then update any info if required. With the proper licencing, you can save the data in the PDF, or have the PDF submit the data back to the web server.

Recently I was given the job of reproducing Contract Notes for clients. The origion is produced by printing the data onto stationary; but as the client wont have the sationary, this is not going to work. No drama for me, I am a CF developer :-)

The first think I did was to open up the PDF in Adobe Acrobat and add fields to the document to create the PDF form. This document is not to be alter by the client so licencing was not an issue. In fact, I get ColdFusion to flatten the file after it is populated so the client can not modify that data and then print it.

In previous of CF, you would hvae to use CFPDF to read the document, then other CF tags to get the fields and poplaute and bluh bluh bluh - doesn't matter any more cos CF8 simplifies all that with a new tag - CFPDFFORM and it's buddy CFPDFFORMPARAM

<cfpdfform source="#pdfPath##pdfDoc#"
                 destination="#pdfPath##pdfTemp#"
                 action="populate"
                 overwrite="yes" >
    <cfpdfformparam name="Branch" value="#qryCnote.BranchName#" />
    <cfpdfformparam name="Advisor" value="#qryCnote.AdvisorName#" />
</cfpdfform>

Just add a CFPDFFORMPARAM for each form field and give it a value <hand in the air and shout> 'Clear!'

And to get rid of the form fields, just use the flatten attributes.

<cfpdf action="write"
           source="#pdfPath##pdfTemp#"
           destination="#pdfPath##pdfTemp#"
           flatten="yes"
           overwrite="yes" />

And finally, push it back to the browser

<cfheader NAME='Content-Disposition'
               VALUE='attachment;filename=#saveAsName#' />
<cfheader name="cache-control" value="" />
<cfheader name="pragma" value="" />

<cftry>
    <cfcontent type="application/pdf"
                    file="#pdfPath##pdfTemp#"
                    deletefile="yes"

                    reset="yes" />
    <cfcatch>
    <!--- prevent unnecessary log entries when user
           cancels download whilst it is in progress
    --->
    </cfcatch>
</cftry>

Posted by AJ Mercer at 3:48 PM - Categories: CFML | ColdFusion