Get Printer Information in CF

Currently, my senior told me to do cfreport to be printed directly without viewing. For this case, I gotta know which printer is available for printer via CFML. Here is coding,

view plain print about
1<cfset printFunction = GetPrinterInfo()>
2<cfset PrinterName = printFunction["printer"]>
To make sure two things for using above coding.

  • all of information from GetPrinterInfo come from Struct data type.
  • Printer must be already connected with CF hosted server. Should not be connected with client PC.

setFocus end of text

I admit, there are so many javascript built-in attributes I haven't known so far. Oddly, createTextRange is one of them which provides the capability to change text and elements on the page. You can use this tag when you want to put cursor at the end of input box. Using this tag is kinda simple :

view plain print about
1ObjName = document.yourform.myinput;
2var ObjRange = ObjName.createTextRange();
3ObjRange.moveStart('character', 1, ObjName.value.length);
4ObjRange.collapse();
5ObjRange.select();

cfprint and cfreport

One of the coolest features of CFMX-8 is cfprint. It's very useful for developers who wanna print any documents on the fly. But, Adobe didn't let us know that we can print our cfreport on the fly. That's why I was on it about how to integrate cfprint with cfreport. Finally, I got it. First of all, we need to save our cfreport as pdf format. After that, point out to this pdf file and print it out with cfprint.

view plain print about
1<cfreport template="MyReport.cfr" query="QryMyReport" format="PDF" filename="MyReport.pdf" overwrite="yes">
2</p>
3<!-- Configure CfPrint -->
4<p>
5<cfset aset=StructNew()>
6<cfset aset["paper"] = "iso-a4">
7<cfset aset["sides"] = "duplex">
8<cfset aset["copies"] = "1">
9<cfset aset["printer"] = "MyPrinter">
10<cfprint type="pdf" source="MyReport.pdf" attributeStruct="#aset#">

CFDiv and CFLayout

Today, I have some free spare time to learn Coldfusion Tags in my office. That's why I decided to learn CFDiv and CFLayout. CFDiv is useful for Ajax manipulation and CFLayout is for content display. That's I'll integrate these two tags.

index.cfm

view plain print about
1<cfform>
2    <cflayout name="outerlayout" type="vbox">
3    <cflayoutarea style="height:100%;">
4        <cflayout name="thelayout" type="border">
5            <cflayoutarea title="Left Panel" position="left" closable="true" collapsible="true" name="left" splitter="true" style="height:100%">
6                <cfinput name="tinput1" type="text">
7                <input type="button" value="Search">
8            </cflayoutarea>
9            <cflayoutarea position="center" style="height:100%">
10                <cfdiv bind="url:divsource.cfm?InputText={tinput1}" ID="theDiv" style="height:350"/>
11            </cflayoutarea>
12        </cflayout>
13        </cflayoutarea>
14    </cflayout>
15</cfform>

divsource.cfm

view plain print about
1<cfoutput>
2<cfif isdefined("url.InputText") AND url.InputText NEQ "">
3    #url.InputText#
4<cfelse>
5    No input
6</cfif>
7</cfoutput>

It stands for every messages will be displayed in the right layout whenever type in the left layout.

cflock

In my past, I didn't know the usage of cflock and how to use, either. In these days, I feel to search cfml tags I didn't know and want to upgrade my knowledge in cfml. First of all, cflock is very new my first observation tags. Using cflock can reduce server memory load. There are two type of cflock called EXCLUSIVE and READONLY.

  • EXCLUSIVE is single-action. It can be accessed by one request in one time. No request can access meanwhile the first request is executing.
  • READONLY is multiple-action. Every request can access but it's readonly. It should be use the shared data to be read not modified.
  • SCOPE are application, server and session. It depends on your variable that you can use which scope will be best for you.

Read detail here http://www.adobe.com/devnet/server_archive/articles/cf_locking_best_practices.html#1 http://www.cfht.hawaii.edu/cfdocs/CFML_Language_Reference/2_ColdFusion_Tags/lr2_058.htm

Font embed for iPhone browser (Safari)

Today I'm testing about font embed for iPhone browser. It's just like font embed style of EOT for Internet Explorer. What I'm gonna show is for all browser specially Internet Explorer, Safari brower (in iPhone either). First of all, we need to create EOT file, SVG and SUGZ file. EOT is especially for Internet Explorer and SVG and SVGZ are for Safari. To generate these files, we need to go http://www.fontsquirrel.com After that, they will generate .eot, .svg and .svgz And, also demo stylesheet. And, open it Safari browser. It's cool.

ENJOY..!!

If you wanna open it from iPhone, you need to jailbreak and test it. Unfortunately, iOS 4.0.2 isn't ready for jailbreak yet.

Migrating Wordpress to MangoBlog

As far as I know, I've got two bugs when migrated Worldpress to MangoBlog.

  • Formatting (Enter) = whenever I formatting, especially "enter" in my paragraph, MangoBlog remove "enter" keycode.
  • Category (Tags) = whenever I gave a tag in my Wordpress posts, MangeBlog change "tags" to "category" and oddly my orginal categories from Wordpress are lost. It's really awesome.

CFEclipes for CFML deverloper

In these days, I'm getting sick of developing CFML pages with homesite5. Because, it doesn't support for cfmx8 tag and sometimes, getting errors and got off. On the other hand, I don't want to install DreamWeaver because it's kinda big and take much of space and memory. That's why I was dilemma between them. So, I was surfing through websites and solving this problems. Finally, I got it eclipse is suitable for CFML developer.

Download Eclipse Here http://www.eclipse.org/downloads

Then follow up this instruction; how to install cfeclipse plug-in in eclipe http://www.dopefly.com/projects/cfeclipse.cfm?CFID=2953264&CFTOKEN=29845399#a1

cfmediaplayer

As we all know, adobe is gradually upgrading their products to be more and more flexible for their developers. Now, Coldfusion reach MX9. Oddly, I haven't deeply touch Mx9 yet because I'm still on MX8. Last week, I was surfing and reading through adobe website about their new products. Coincidently, I've found which is more flexible for Video and Advertisement webiste protal. We gotta use for putting video files when we're on MX8. Now, we don't need to use this coding if we upgrade our server to MX9. Is that great, huh?

You can read more cfmediaplayer here.

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSE66DB0CD-E16D-49e7-AAEE-F51F9580554E.html

Likewise, Microsoft recently launched .NET framework 4.0 for their developers. They praised that 4.0 can strongly support more reusable, rich application and so on.

Google App Engine data manipulation with Coldfusion

Today, I've recently developed one simple project with Coldfusion in Google App Engine. To manipulate data in Google App Engine is complicated because we can use only GQL (Google Query Language) instead of SQL. Likewise, displaying data in Google App Engine with OpenBD is quite different with Adobe Coldfusion. That's why, it's too hard to handle to everything. Ok, I'll show how to create Table in Google App Engine and retrieve data either.

Create Table and Insert Data

view plain print about
1<cfscript>
2    car = StructNew();
3    car["Class"] = "Sedan-Midsize";
4    car["Make"] = "Audi";
5    car["Model"] = "A6";
6    keyString = googleWrite(car, "MyCarLot");
7
</cfscript>

Ref : http://wiki.openbluedragon.org/wiki/index.php/GoogleAppEngine:Datastore

Display data

view plain print about
1<cfquery dbtype="google" name="QryCar">
2    select from MyCarLot
3</cfquery>
4    
5<cfloop from="1" to="#ArrayLen(QryCar)#" index="i">
6    <cfoutput> #getAllTags[i].Class# </cfoutput>
7</cfloop>

Top of Page