Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
1615 lines (1171 loc) · 90.2 KB
/
Copy pathindex.html
File metadata and controls
1615 lines (1171 loc) · 90.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
<meta charset="utf-8">
<title>Nando @ Aria Media</title>
<meta name="author" content="Nando @ Aria Media">
<meta name="description" content="When using an SQL IN statement within a ColdFusion query, it is necessary to add the attribute list="true" to the param used for the list. See the …">
<!-- http://t.co/dKP3o1e -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="canonical" href="http://dnando.github.io">
<link href="/favicon.png" rel="icon">
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
<link href="/atom.xml" rel="alternate" title="Nando @ Aria Media" type="application/atom+xml">
<script src="/javascripts/modernizr-2.0.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>!window.jQuery && document.write(unescape('%3Cscript src="./javascripts/libs/jquery.min.js"%3E%3C/script%3E'))</script>
<script src="/javascripts/octopress.js" type="text/javascript"></script>
<!--Fonts from Google"s Web font directory at http://google.com/webfonts -->
<link href="//fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">
<link href="//fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">
<link href='//fonts.googleapis.com/css?family=Oxygen:400,300,700' rel='stylesheet' type='text/css'>
</head>
<body >
<header role="banner"><hgroup>
<h1><a href="/">Nando @ Aria Media</a></h1>
<h2>( learning Clojure ColdFusion Lucee Javascript jQuery Angular CSS Linux Apache HTML5 & etc )</h2>
</hgroup>
</header>
<nav role="navigation"><ul class="subscription" data-subscription="rss">
<li><a href="/atom.xml" rel="subscribe-rss" title="subscribe via RSS">RSS</a></li>
</ul>
<form action="https://www.google.com/search" method="get">
<fieldset role="search">
<input type="hidden" name="q" value="site:dnando.github.io" />
<input class="search" type="text" name="q" results="0" placeholder="Search"/>
</fieldset>
</form>
<ul class="main-navigation">
<li><a href="/">Blog</a></li>
<li><a href="/blog/archives">Archives</a></li>
<li><a href="/about-me">About Me</a></li>
<li><a href="http://aria-media.com/">Aria Media</a></li>
</ul>
</nav>
<div id="main">
<div id="content">
<div class="blog-index">
<article>
<header>
<h1 class="entry-title"><a href="/blog/2017/04/09/cfqueryparam-setting-for-sql-in-statements/">Cfqueryparam Setting for SQL ‘in’ Statements</a></h1>
<p class="meta">
<time class='entry-date' datetime='2017-04-09T01:32:33+02:00'><span class='date'><span class='date-month'>Apr</span> <span class='date-day'>9</span><span class='date-suffix'>th</span>, <span class='date-year'>2017</span></span> <span class='time'>1:32 am</span></time>
| <a href="/blog/2017/04/09/cfqueryparam-setting-for-sql-in-statements/#disqus_thread"
data-disqus-identifier="http://dnando.github.io/blog/2017/04/09/cfqueryparam-setting-for-sql-in-statements/">Comments</a>
</p>
</header>
<div class="entry-content"><p>When using an SQL IN statement within a ColdFusion query, it is necessary to add the attribute <code>list="true"</code> to the param used for the list. See the example below that selects all employees that have a birthdate in March, April or May.</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>public query function findUpcomingBirthdates() {
</span><span class='line'> var params = {};
</span><span class='line'> var ml = "3,4,5";
</span><span class='line'> params.insert( "monthList", { value: ml, cfsqltype: "cf_sql_integer", list: true } );
</span><span class='line'> var sql = "
</span><span class='line'> select employeeId, firstName, lastName, birthdate
</span><span class='line'> from Employee
</span><span class='line'> where month( birthdate ) in ( :monthList )
</span><span class='line'> ";
</span><span class='line'> return queryExecute( sql, params );
</span><span class='line'>}</span></code></pre></td></tr></table></div></figure>
<p>Thanks to Ben Nadel’s post <a href="https://www.bennadel.com/blog/425-coldfusion-cfqueryparam-list-attribute-is-sweeet.htm">here</a> for this crucial tidbit of information!</p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2017/03/20/hot-browser-reloading/">Hot Browser Reloading With Browsersync</a></h1>
<p class="meta">
<time class='entry-date' datetime='2017-03-20T00:06:28+01:00'><span class='date'><span class='date-month'>Mar</span> <span class='date-day'>20</span><span class='date-suffix'>th</span>, <span class='date-year'>2017</span></span> <span class='time'>12:06 am</span></time>
| <a href="/blog/2017/03/20/hot-browser-reloading/#disqus_thread"
data-disqus-identifier="http://dnando.github.io/blog/2017/03/20/hot-browser-reloading/">Comments</a>
</p>
</header>
<div class="entry-content"><p>I’ve fallen down the rabbit hole of front end development in the last few weeks, and in that time <a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/">Flexbox CSS</a>, <a href="http://blog.getbootstrap.com/2017/01/06/bootstrap-4-alpha-6/">Bootstrap v4</a>, <a href="http://foundation.zurb.com/">Foundation</a>, <a href="http://sass-lang.com/guide">Sass / SCSS</a>, and <a href="http://gulpjs.com/">Gulp</a> have all whizzed by as I’ve taught myself portions of each, and today I landed at the bottom, <a href="https://www.browsersync.io/">Browsersync</a>.</p>
<p>In a nutshell, Browsersync will live reload one or more browsers for you whenever your project’s files change. It will also live reload external devices pointed at the same web application. This allows you to simultaneously and efficiently test a responsive design in multiple browsers, phones and tablets - without needing to touch or reload any of them. It also synchronizes form entries and clicks across browsers and devices. For example, with my phone and tablet connected to Browsersync, I log into the app I’m developing on the tablet, and my keystrokes and touch gestures are replicated on the phone, and I’m logged in on both. Then I start navigating in the application in Chrome on my desktop, and the phone, tablet and other browsers follow as “slaves”. Interacting with any interface causes the rest of them to follow. What an incredible tool! In the few minutes I’ve been experimenting with it, I was able to easily and quickly fix a layout issue on the tablet and phone for the login screen.</p>
<p>Browsersync works by wrapping your application or website in its own Node server process, on another port. You can start Browsersync on the command line, or via a Grunt or Gulp task. During startup, you specify the local url of your app, the files you want it to watch - a number of other options are possible - and then a browser window opens, on port 3000 by default, and browsersync is activated for that browser. To add others, you simply use the same url. To add external devices, on localhost:3001 there is an admin panel for Browsersync that will list the external url to use. Navigate to that external url on your phone or tablet or another computer, for me it currently <a href="http://192.168.1.103:3000/,">http://192.168.1.103:3000/,</a> and Browsersync is set up on these devices as well. Once you have it configured, it is really simple to use.</p>
<p>A quick overview on installation and configuration: Basic instructions are on the homepage <a href="https://www.browsersync.io/.">https://www.browsersync.io/.</a></p>
<ol>
<li>Install or upgrade Node.js</li>
<li>Install Browsersync using npm</li>
</ol>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>npm install -g browser-sync</span></code></pre></td></tr></table></div></figure>
<p>The -g flag means global so it is available from anywhere.</p>
<ol>
<li>Start Browsersync</li>
</ol>
<p>There are 2 start modes, –server and –proxy. <em>server</em> is for static files, <em>proxy</em> is for applications running on a server. Here’s a simplified example starting Browsersync from the command line:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>browser-sync start --proxy "myproject.dev" --files "css/*.css"</span></code></pre></td></tr></table></div></figure>
<p>… assuming you have your local host file set up to point your app at myproject.dev. Or you can also start Browsersync using a localhost:port url, like this:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>browser-sync start --proxy "localhost:8500/myproject" --files "css/*.css"</span></code></pre></td></tr></table></div></figure>
<p>There are a few real world ways to do this, but what I’ve done is to create a gulpfile.js in the root of my project so I can configure Browsersync conveniently and start it with a simple gulp command after cd’ing in to my project directory. That way I don’t have to remember much. Here’s my first working gulpfile.js for a real development scenario. I have ACF (Adobe ColdFusion) installed on port 8501 on my dev laptop, and gulp.watch() is configured for an FW/1 app. I’m not sure if I actually want to watch the controllers and services directories, perhaps the views directory and CSS directory is enough. But for now I will leave it like this and see how it goes.</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>var gulp = require('gulp');
</span><span class='line'>var browserSync = require('browser-sync').create();
</span><span class='line'>var reload = browserSync.reload;
</span><span class='line'>
</span><span class='line'>gulp.task('browser-sync', function() {
</span><span class='line'> browserSync.init({
</span><span class='line'> proxy: "localhost:8501/myproject"
</span><span class='line'> });
</span><span class='line'>
</span><span class='line'> gulp.watch([
</span><span class='line'> 'controllers/*.cfc', 'services/*.cfc', 'views/**/*.cfm', 'dist/*.css'
</span><span class='line'> ]).on("change", function() {
</span><span class='line'> console.log("Watch hit");
</span><span class='line'> browserSync.reload();
</span><span class='line'> });
</span><span class='line'>});
</span><span class='line'>
</span><span class='line'>gulp.task('default', ['browser-sync']);</span></code></pre></td></tr></table></div></figure>
<p>Note carefully the syntax of gulp.watch() for multiple directories / files. It’s an array of strings separated by commas. Note also that the root of the relative paths specified is where the gulpfile.js is located.</p>
<p>But wait, wouldn’t it be better if I could use Browsersync to develop against both ACF and Lucee? Here’s a solution that I have working that creates named instances of Browsersync so they don’t step on each other:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>var gulp = require('gulp');
</span><span class='line'>var bsacf = require('browser-sync').create('browserSyncACF');
</span><span class='line'>var bslucee = require('browser-sync').create('browserSyncLucee');
</span><span class='line'>
</span><span class='line'>gulp.task('browser-sync', function() {
</span><span class='line'> bsacf.init({
</span><span class='line'> proxy: "localhost:8501/myproject",
</span><span class='line'> browser: "google chrome",
</span><span class='line'> reloadOnRestart: true
</span><span class='line'> });
</span><span class='line'>
</span><span class='line'> bslucee.init({
</span><span class='line'> proxy: "localhost:8888/myproject",
</span><span class='line'> browser: "vivaldi",
</span><span class='line'> port: 3010,
</span><span class='line'> reloadOnRestart: true,
</span><span class='line'> ui: {
</span><span class='line'> port: 3011
</span><span class='line'> }
</span><span class='line'> });
</span><span class='line'>
</span><span class='line'> gulp.watch([
</span><span class='line'> 'controllers/*.cfc', 'services/*.cfc', 'views/**/*.cfm', 'dist/*.css'
</span><span class='line'> ]).on("change", function() {
</span><span class='line'> console.log("Watch hit");
</span><span class='line'> bsacf.reload();
</span><span class='line'> bslucee.reload();
</span><span class='line'> });
</span><span class='line'>});
</span><span class='line'>
</span><span class='line'>gulp.task('default', ['browser-sync']);</span></code></pre></td></tr></table></div></figure>
<p>I specify separate browsers for each so that ACF and Lucee sessions don’t step on one another, and separate ports for the Lucee instance of Browsersync so they can coexist. The advantage to doing it this way is I can start both instances with a single <em>gulp</em> command on the command line. Unfortunately the ACF and Lucee instances of Browsersync will not mirror or ghost each other, so I will still have to click and enter test data on forms separately while developing, but this is still much better than needing to reload both browsers manually all the time.</p>
<h5>Update:</h5>
<p>I’ve noticed one other feature of Browsersync that I wanted to see if I could get working - injecting modified CSS into the browser to avoid reloading the DOM. I’ve now rearranged my gulpfile.js to be the following, adding a second gulp.watch() call to inject the minified bootstrap css directly into the browser, and removing the <em>dist</em> directory from the first gulp.watch() call so the browsers are not reloaded.</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
<span class='line-number'>40</span>
<span class='line-number'>41</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>var gulp = require('gulp');
</span><span class='line'>var bsacf = require('browser-sync').create('browserSyncACF');
</span><span class='line'>var bslucee = require('browser-sync').create('browserSyncLucee');
</span><span class='line'>
</span><span class='line'>gulp.task('browser-sync', function() {
</span><span class='line'> bsacf.init({
</span><span class='line'> proxy: "localhost:8501/easycal",
</span><span class='line'> browser: "google chrome",
</span><span class='line'> reloadOnRestart: true
</span><span class='line'> });
</span><span class='line'>
</span><span class='line'> bslucee.init({
</span><span class='line'> proxy: "localhost:8888/easycal",
</span><span class='line'> browser: "vivaldi",
</span><span class='line'> port: 3010,
</span><span class='line'> reloadOnRestart: true,
</span><span class='line'> ui: {
</span><span class='line'> port: 3011
</span><span class='line'> }
</span><span class='line'> });
</span><span class='line'>
</span><span class='line'> gulp.watch([
</span><span class='line'> 'controllers/*.cfc', 'services/*.cfc', 'views/**/*.cfm',
</span><span class='line'> 'layouts/**/*.cfm', 'dist/*.css', 'easycal-app.css'
</span><span class='line'> ]).on("change", function() {
</span><span class='line'> console.log("Watch hit");
</span><span class='line'> bsacf.reload();
</span><span class='line'> bslucee.reload();
</span><span class='line'> });
</span><span class='line'>
</span><span class='line'> gulp.watch([
</span><span class='line'> 'dist/toolkit.min.css'
</span><span class='line'> ]).on("change", function() {
</span><span class='line'> console.log("CSS hit");
</span><span class='line'> return gulp.src(['dist/toolkit.min.css'])
</span><span class='line'> .pipe(bsacf.stream())
</span><span class='line'> .pipe(bslucee.stream());
</span><span class='line'> });
</span><span class='line'>});
</span><span class='line'>
</span><span class='line'>gulp.task('default', ['browser-sync']);</span></code></pre></td></tr></table></div></figure>
<p>I like how this is shaping up now. :-)</p>
<p>Comments or suggestions welcome!</p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2016/08/05/scale-attribute-is-essential-with-decimal-cfsqltype/">Scale Attribute Is Essential With Decimal Cfsqltype</a></h1>
<p class="meta">
<time class='entry-date' datetime='2016-08-05T00:22:47+02:00'><span class='date'><span class='date-month'>Aug</span> <span class='date-day'>5</span><span class='date-suffix'>th</span>, <span class='date-year'>2016</span></span> <span class='time'>12:22 am</span></time>
| <a href="/blog/2016/08/05/scale-attribute-is-essential-with-decimal-cfsqltype/#disqus_thread"
data-disqus-identifier="http://dnando.github.io/blog/2016/08/05/scale-attribute-is-essential-with-decimal-cfsqltype/">Comments</a>
</p>
</header>
<div class="entry-content"><p>I just ran across something important to know regarding the cfsqltype cf_sql_decimal. Here’s the code I was testing:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>params.insert( 'previousNumericDuration',
</span><span class='line'> { value: preNDuration, cfsqltype: 'cf_sql_decimal' } );</span></code></pre></td></tr></table></div></figure>
<p>Here’s what it would look like if you are using the cfqueryparam tag:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'><cfqueryparam value='#preNDuration#' cfsqltype='cf_sql_decimal' /></span></code></pre></td></tr></table></div></figure>
<p>The database column this is persisted to is defined as a <code>decimal(4,2)</code>, so 2 digits are reserved for the whole number portion of the value and 2 digits reserved for the decimal portion of the value. Logging showed values being calculated such as 4.25 and 4.5, but these were being persisted to the database rounded to the nearest integer, but with 2 decimal places none the less, so 4.25 was persisted as <em>4.00</em> and 4.5 was persisted as <em>5.00</em>. Definitely not what I wanted. What’s the point of a decimal datatype if the decimal portion is always 0?</p>
<p>Digging into the documentation for cfqueryparam I found a scale attribute that until today I hadn’t realized was absolutely essential to use for decimal fields like this. Scale defines the … “Number of decimal places in parameter. Applies to CF_SQL_NUMERIC and CF_SQL_DECIMAL.” Its default is 0, so my values were being rounded to 0 decimal places. After changing my code to the following:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>params.insert( 'previousNumericDuration',
</span><span class='line'> { value: preNDuration, cfsqltype: 'cf_sql_decimal', scale: 2 } );</span></code></pre></td></tr></table></div></figure>
<p>the decimal portion of the values was then persisted correctly.</p>
<p>So the <em>scale</em> attribute is absolutely essential for a <em>decimal</em> cfsqltype. I might have tripped over this before, I’m not sure. Perhaps this blog post will help me remember it next time. Now I should search my code to see if I’ve neglected this attribute elsewhere!</p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2016/03/22/first-steps-with-the-clojure-version-of-fw-slash-1/">First Steps With the Clojure Version of FW/1</a></h1>
<p class="meta">
<time class='entry-date' datetime='2016-03-22T20:45:04+01:00'><span class='date'><span class='date-month'>Mar</span> <span class='date-day'>22</span><span class='date-suffix'>nd</span>, <span class='date-year'>2016</span></span> <span class='time'>8:45 pm</span></time>
| <a href="/blog/2016/03/22/first-steps-with-the-clojure-version-of-fw-slash-1/#disqus_thread"
data-disqus-identifier="http://dnando.github.io/blog/2016/03/22/first-steps-with-the-clojure-version-of-fw-slash-1/">Comments</a>
</p>
</header>
<div class="entry-content"><p>Sean Corfield has built a Clojure version of the popular CFML framework FW/1. I’ve been using FW/1 for a number of years, so I thought it might help me learn Clojure to begin developing an app in fw1-clj.</p>
<p>The first step to get up and running is to head on over to the <a href="https://github.com/framework-one/fw1-clj">fw1-clj GitHub repository</a> and follow the directions to <a href="https://github.com/boot-clj/boot#install">install Boot</a>, which is a build tool for Clojure. Next, as per the instructions on the fw1-clj GitHub repository, we run a boot command in a terminal to create a new fw1-clj app, which currently looks like this:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>boot -d seancorfield/boot-new new -t fw1 -n myfw1app
</span></code></pre></td></tr></table></div></figure>
<p>(Sean has indicated this invocation may change in the future, so best to follow the fw1-clj repository instructions.)</p>
<p>Then, we “cd” into the application directory we specified above, in this example “myfw1app”, and start the application up like so:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nb">cd </span>myfw1app
</span><span class='line'><span class="nv">PORT</span><span class="o">=</span><span class="m">8111</span> boot run
</span></code></pre></td></tr></table></div></figure>
<p>Specifying the PORT variable isn’t required, but may be necessary to avoid conflicts. If omitted, the default port is 8080.</p>
<p>Navigating to localhost:8111, we see a lovely default page that says “Framework One - Welcome to FW/1”. Yay! It certainly is impressive how easy that is. No server to install. Nothing to download. No settings to find and configure. We’re ready to start developing.</p>
<p>There are several options to choose from in terms of an IDE for Clojure. Many experienced Clojure developers use <a href="https://www.gnu.org/software/emacs/">Emacs</a> with <a href="https://github.com/clojure-emacs/cider">CIDER</a>, or the <a href="https://cursive-ide.com/userguide/index.html">Cursive plugin</a> for <a href="https://www.jetbrains.com/idea/download/index.html">Intellij</a>. Both of those have a learning curve that you may prefer to avoid to focus on getting the basics of Clojure down first.</p>
<p>For beginners, good IDE’s for experimentation are <a href="http://lighttable.com/">Light Table</a> or <a href="https://atom.io/">Atom</a> with <a href="https://atom.io/packages/search?q=clojure">a few Clojure packages</a> installed, such as language-clojure, proto-repl and parinfer. I’m using Atom at the moment because I’m also using it for CFML development, and also because the Clojure packages seem to work very well.</p>
<p>One of the first things I wanted to figure out was how to visualize the rc map (or struct as it would be known in CFML). With a tip from Sean, I navigated to src/projectName/controllers/main.clj in the project that boot generated for me, and within the default function definition, I added <code>(println rc)</code></p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='clojure'><span class='line'><span class="p">(</span><span class="kd">defn </span><span class="nv">default</span> <span class="s">"/main/default handler"</span> <span class="p">[</span><span class="nv">rc</span><span class="p">]</span>
</span><span class='line'> <span class="p">(</span><span class="nb">println </span><span class="nv">rc</span><span class="p">)</span>
</span><span class='line'> <span class="nv">rc</span><span class="p">)</span>
</span></code></pre></td></tr></table></div></figure>
<p>reloaded the app in the browser, and then checked the terminal window where I had started the app with the boot command for the output. Nothing was output there. After a moment, I remembered that I probably had to reload the application to get the changes picked up. Checking the somewhat sparse documentation on the Github page, I found the default reload query string would be “?reload=secret”. Hitting localhost:8111?reload=secret in the browser then generated the rc map in my terminal window - all in one <em>very</em> long line. After another suggestion from Sean, I replaced the print line function <code>(println rc)</code> with the clojure pretty print function <code>(clojure.pprint/pprint rc)</code></p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='clojure'><span class='line'><span class="p">(</span><span class="kd">defn </span><span class="nv">default</span> <span class="s">"/main/default handler"</span> <span class="p">[</span><span class="nv">rc</span><span class="p">]</span>
</span><span class='line'> <span class="p">(</span><span class="nf">clojure.pprint/pprint</span> <span class="nv">rc</span><span class="p">)</span>
</span><span class='line'> <span class="nv">rc</span><span class="p">)</span>
</span></code></pre></td></tr></table></div></figure>
<p>hit localhost:8111?reload=secret again, and now the keys within the rc map were nicely separated by line breaks in the terminal output. Much more readable that way.</p>
<p>I noticed within the output that the :reload-application-on-every-request key was set to false. Better in development to have that set to true, so reading the docs, I found “the call to (fw1/start) can be passed configuration parameters either as a map or as an arbitrary number of inline key / value pairs”</p>
<p>Ok, so opening src/projectName/main.clj, I found the call to (fw1/start) and changed it from</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='clojure'><span class='line'><span class="p">(</span><span class="kd">defn </span><span class="nv">-main</span> <span class="p">[]</span>
</span><span class='line'> <span class="p">(</span><span class="k">let </span><span class="p">[</span><span class="nv">port</span> <span class="p">(</span><span class="nf">Integer/parseInt</span> <span class="p">(</span><span class="nb">get </span><span class="p">(</span><span class="nf">System/getenv</span><span class="p">)</span> <span class="s">"PORT"</span> <span class="s">"8080"</span><span class="p">))]</span>
</span><span class='line'> <span class="p">(</span><span class="nf">run-jetty</span> <span class="p">(</span><span class="nf">fw1/start</span> <span class="ss">:application-key</span> <span class="s">"easycalclj"</span><span class="p">)</span>
</span><span class='line'> <span class="p">{</span><span class="ss">:port</span> <span class="nv">port</span><span class="p">})))</span>
</span></code></pre></td></tr></table></div></figure>
<p>to</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='clojure'><span class='line'><span class="p">(</span><span class="kd">defn </span><span class="nv">-main</span> <span class="p">[]</span>
</span><span class='line'> <span class="p">(</span><span class="k">let </span><span class="p">[</span><span class="nv">port</span> <span class="p">(</span><span class="nf">Integer/parseInt</span> <span class="p">(</span><span class="nb">get </span><span class="p">(</span><span class="nf">System/getenv</span><span class="p">)</span> <span class="s">"PORT"</span> <span class="s">"8080"</span><span class="p">))]</span>
</span><span class='line'> <span class="p">(</span><span class="nf">run-jetty</span> <span class="p">(</span><span class="nf">fw1/start</span> <span class="ss">:application-key</span> <span class="s">"easycalclj"</span> <span class="ss">:reload-application-on-every-request</span> <span class="s">"true"</span><span class="p">)</span>
</span><span class='line'> <span class="p">{</span><span class="ss">:port</span> <span class="nv">port</span><span class="p">})))</span>
</span></code></pre></td></tr></table></div></figure>
<p>Then I reloaded the app with “?reload=secret”, and the rc output for :reload-application-on-every-request didn’t change. Hmmm …</p>
<p>After a bit of investigation, (I asked Sean again on Slack), I found that to reload changes to the configuration params, I needed to go to the terminal window where I started the app with <code>boot run</code>, shut the app down with <code>control-c</code>, and then start it up again with <code>PORT=8111 boot run</code>.</p>
<p>Checking the rc output in the console again, I saw that :reload-application-on-every-request was now true!</p>
<p>These were all small baby steps, but unless I take them, I won’t learn.</p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2015/07/01/generating-accurate-pdfs-using-cfdocument/">Generating Accurate PDFs Using Cfdocument</a></h1>
<p class="meta">
<time class='entry-date' datetime='2015-07-01T23:55:41+02:00'><span class='date'><span class='date-month'>Jul</span> <span class='date-day'>1</span><span class='date-suffix'>st</span>, <span class='date-year'>2015</span></span> <span class='time'>11:55 pm</span></time>
| <a href="/blog/2015/07/01/generating-accurate-pdfs-using-cfdocument/#disqus_thread"
data-disqus-identifier="http://dnando.github.io/blog/2015/07/01/generating-accurate-pdfs-using-cfdocument/">Comments</a>
</p>
</header>
<div class="entry-content"><p>I’ve been developing a PDF, generated within a CFML application, that needs very accurate placement of chunks of text so that it can be printed on a standard form. It also needs to use a specified font, OCR-B, so that a line of text on the printed form can be machine scanned. I’ve managed to get this working much better than expected on both ACF and Lucee, in a cross-compatible way, so I thought I’d write everything up to remember the details down the line.</p>
<p>I was at first thinking I might be able to use the new cfhtmltopdf tag, but quickly dropped that idea: I couldn’t get the PDF Service needed to use this tag to work on my Mac; it seems to be an enterprise only feature; and I wasn’t so sure this approach would be compatible to use within Lucee. After looking around over the fence for a bit at potential solutions outside of CFML, nothing hit me as particularly appealing, so I dug into getting cfdocument to work as best I could. First the tag attributes.</p>
<h2>Attributes</h2>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'><cfdocument format="pdf" pagetype="A4" orientation="portrait" fontEmbed="true" unit="cm" localUrl="true" saveAsName="#pdfFileName#" marginLeft="0" margintop="0" marginright="0" marginbottom="0"></span></code></pre></td></tr></table></div></figure>
<p>FontEmbed=“true” is essential so that anyone can print the PDF with the OCR-B code line correctly displayed, even if they don’t have this font on their system. LocalUrl is set to true to easily pull in a logo image from the local file system. Note the margins are set to 0, because I’m using a <code><div></code> tag to define the size of the page to control the tendency of the 2 different PDF generation engines used in ACF and Lucee to scale the layout, differently.</p>
<h2>Layout</h2>
<p>Nested directly within the cfdocument tag is a div tag that sets the page width, with <code>position:relative</code> so it remains within the page flow, and acts as the parent tag within which all layout divs that position text are nested <em>and proportionally scaled against</em>:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'><div style="position:relative; top:0mm; left:0mm; width:210mm;"></span></code></pre></td></tr></table></div></figure>
<p>Then within that parent div tag are nested the various div tags, absolutely positioned, containing the blocks of text and images that make up the PDF content. Here are a few examples to demonstrate:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class=''><span class='line'><div class="address" style="position:absolute; top:13mm; left:100mm; ">
</span><span class='line'> #biller.address1# · #biller.zipcode# #biller.city#
</span><span class='line'></div>
</span><span class='line'><!--- client address --->
</span><span class='line'><div class="text" style="position:absolute; top:45mm; left:130mm">
</span><span class='line'> #invoice.getClient().getName()#<br>
</span><span class='line'> <cfif len( trim( invoice.getClient().getAddress1() ) )>#invoice.getClient().getAddress1()#<br></cfif>
</span><span class='line'> <cfif len( trim( invoice.getClient().getAddress2() ) )>#invoice.getClient().getAddress2()#<br></cfif>
</span><span class='line'> <cfif len( trim( invoice.getClient().getAddress3() ) )>#invoice.getClient().getAddress3()#<br></cfif>
</span><span class='line'> #invoice.getClient().getCountryCode()#-#invoice.getClient().getZipCode()# #invoice.getClient().getCity()#
</span><span class='line'></div></span></code></pre></td></tr></table></div></figure>
<p>What I really like about this approach is that each of the text blocks winds up very close to the top and left dimensions specified, and the ACF and Lucee outputs are nearly identical.</p>
<p>Without the parent div tag specifying the width, the results between the 2 engines are vastly different, and positioning the elements is much more a question of trial and error than simply entering the top and left positions as measured with a ruler (and perhaps tweaking them by a few milimeters if necessary). Also without the parent div tag to control how layout elements scale, changing the dimension of one absolutely positioned div within the PDF can easily alter the position or size of other divs, which can be very frustrating if you have 20 or 30 elements that all need to be precisely positioned.</p>
<p>Feel free to experiment with paddings or margins on the parent div if you want - I suspect it would work just as well (but haven’t tried). For myself, I found it easier simply to measure placement from the edge of the page.</p>
<p>I haven’t tried this myself, yet, but I have it from a reliable source that a parent div tag in the layout specifying the page width, as above, will fix page break issues if a table extends over more than one page.</p>
<h2>Fonts</h2>
<p>Specifying a font for a block of text is simple. You can use a CSS style declaration within a style block that is nested <em>within</em> the cfdocument tag, or you can place the font specification directly in a style attribute of an html tag like `<div> <span> <td>. Here are the styles I used for the above text blocks (and again, the style block must be nested within the cfdocument tag, or the PDF generator won’t see it):</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
</pre></td><td class='code'><pre><code class=''><span class='line'><cfdocument format="pdf" pagetype="A4" orientation="portrait" fontEmbed="true" unit="cm" localUrl="true" saveAsName="#pdfFileName#" marginLeft="0" margintop="0" marginright="0" marginbottom="0">
</span><span class='line'><style>
</span><span class='line'> div.text {
</span><span class='line'> font: 9pt Arial;
</span><span class='line'> line-height: 13pt;
</span><span class='line'> }
</span><span class='line'>
</span><span class='line'> div.address {
</span><span class='line'> font: 9pt Arial;
</span><span class='line'> color: #033B7D;
</span><span class='line'> }
</span><span class='line'> ...
</span><span class='line'></style>
</span></code></pre></td></tr></table></div></figure>
<p>As of this writing, available CSS attributes remain limited. There is a list of CSS attributes that work in the ACF documentation for cfdocument, reproduced here:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
<span class='line-number'>40</span>
<span class='line-number'>41</span>
<span class='line-number'>42</span>
<span class='line-number'>43</span>
<span class='line-number'>44</span>
<span class='line-number'>45</span>
<span class='line-number'>46</span>
<span class='line-number'>47</span>
<span class='line-number'>48</span>
<span class='line-number'>49</span>
<span class='line-number'>50</span>
<span class='line-number'>51</span>
<span class='line-number'>52</span>
<span class='line-number'>53</span>
<span class='line-number'>54</span>
<span class='line-number'>55</span>
<span class='line-number'>56</span>
<span class='line-number'>57</span>
<span class='line-number'>58</span>
<span class='line-number'>59</span>
<span class='line-number'>60</span>
<span class='line-number'>61</span>
<span class='line-number'>62</span>
<span class='line-number'>63</span>
<span class='line-number'>64</span>
<span class='line-number'>65</span>
<span class='line-number'>66</span>
<span class='line-number'>67</span>
<span class='line-number'>68</span>
<span class='line-number'>69</span>
<span class='line-number'>70</span>
<span class='line-number'>71</span>
<span class='line-number'>72</span>
<span class='line-number'>73</span>
<span class='line-number'>74</span>
<span class='line-number'>75</span>
<span class='line-number'>76</span>
<span class='line-number'>77</span>
<span class='line-number'>78</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>The cfdocument tag supports the following CSS styles:
</span><span class='line'>
</span><span class='line'>background
</span><span class='line'>background-attachment
</span><span class='line'>background-color
</span><span class='line'>background-image
</span><span class='line'>background-position
</span><span class='line'>background-repeat
</span><span class='line'>border
</span><span class='line'>border-bottom
</span><span class='line'>border-bottom-color
</span><span class='line'>border-bottom-style (solid border only)
</span><span class='line'>border-bottom-width
</span><span class='line'>border-color
</span><span class='line'>border-left
</span><span class='line'>border-left-color
</span><span class='line'>border-left-style (solid border only)
</span><span class='line'>border-left-width
</span><span class='line'>border-right
</span><span class='line'>border-right-color
</span><span class='line'>border-right-style (solid border only)
</span><span class='line'>border-right-width
</span><span class='line'>border-spacing
</span><span class='line'>border-style (solid border only)
</span><span class='line'>border-top
</span><span class='line'>border-top-color
</span><span class='line'>border-top-style (solid border only)
</span><span class='line'>border-top-width
</span><span class='line'>border-width
</span><span class='line'>bottom
</span><span class='line'>clear
</span><span class='line'>clip
</span><span class='line'>color
</span><span class='line'>content (strings, counters only)
</span><span class='line'>counter-increment
</span><span class='line'>counter-reset
</span><span class='line'>cursor
</span><span class='line'>display
</span><span class='line'>float
</span><span class='line'>font
</span><span class='line'>font-family
</span><span class='line'>font-size
</span><span class='line'>font-style
</span><span class='line'>font-weight
</span><span class='line'>height
</span><span class='line'>left
</span><span class='line'>letter-spacing
</span><span class='line'>line-height
</span><span class='line'>list-style-type
</span><span class='line'>margin
</span><span class='line'>margin-bottom
</span><span class='line'>margin-left
</span><span class='line'>margin-right
</span><span class='line'>margin-top
</span><span class='line'>outline
</span><span class='line'>outline-color
</span><span class='line'>outline-style (solid, dotted, dashed only)
</span><span class='line'>outline-width
</span><span class='line'>padding
</span><span class='line'>padding-bottom
</span><span class='line'>padding-left
</span><span class='line'>padding-right
</span><span class='line'>padding-top
</span><span class='line'>page-break-after
</span><span class='line'>page-break-before
</span><span class='line'>page-break-inside
</span><span class='line'>position
</span><span class='line'>right
</span><span class='line'>text-align (left, right, and center)
</span><span class='line'>text-decoration
</span><span class='line'>text-indent
</span><span class='line'>top
</span><span class='line'>unicode-bidi
</span><span class='line'>vertical-align
</span><span class='line'>visibility
</span><span class='line'>white space (normal, nowrap only)
</span><span class='line'>width
</span><span class='line'>z-index</span></code></pre></td></tr></table></div></figure>
<h2>Custom fonts</h2>
<p>Scattered around the internet I found a variety of comments suggesting that getting a “custom” font to work within cfdocument isn’t at all easy. Once you know how, it’s actually fairly simple. For both ACF and Lucee, it’s a question of getting the correct font file in the right place, with the right permissions, and restarting ACF/Lucee.</p>
<p>For ACF, log into the administrator and go to the Font Management Panel. There you will see all the fonts available to use in cfdocument … except that as of this writing, the OTF fonts won’t work, even tho’ the Font Management panel claims they are useable in PDFs. Unless something changes in the future, forget OTF fonts for cfdocument. I tried a bunch that already seemed to be recognized, none worked.</p>
<p>At the top of the font panel, you’ll see a feature that allows you to add fonts “Register New Font(s) with ColdFusion”. I couldn’t get this to work reliably - I think the validation routine on it isn’t well designed. Go ahead and try if you like, but I found it easier to simply find a path to a font directory already recognized by ACF from the list of fonts installed ( I chose a directory with TTF files, just to be sure ), copy the TTF font files you want to use to that directory, change the owner/group and permissions to match the other font files in that directory (if necessary on your OS), restart ACF, log back into the administrator, go to the Font Management panel again and look for your fonts. In the left columns of the font table there are 3 names, Font Family, Font Face, Postscript Name. From my experience, using the font face name in your CSS specification should work. ( If not, try the other names - I saw a post suggesting that. )</p>
<p>To be clear, after you get the font installed in a directory that ACF recognizes as a font directory, one way or another, you’ll need to find the name you need to use in your CSS. The file name often does not match the font name.</p>
<p>For Lucee, the process is different. ;-) Go to your Lucee installation directory, and within the /lib/ directory underneath it, find the fonts.jar file. Copy it to a working directory, rename the copy to fonts.zip and unzip it. ( A .jar file is essentially a ZIP file ). In the unzipped <em>fonts</em> directory that results, add your custom font files, again use only TTFs, and then open the pd4fonts.properties file you find in there and following the pattern you see, add the names of the fonts. In Lucee, you can choose the name, but to be cross compatible with ACF, I used the same name that ACF picked up from the font file. Here’s what my pd4fonts.properties looked like after I added the OCR-B font I needed:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>#this is an autogenerated file. please remove manually any references to copyrighted fonts
</span><span class='line'>#Fri Apr 17 20:00:52 CEST 2009
</span><span class='line'>Arial=arial.ttf
</span><span class='line'>Arial\ Bold=arialbd.ttf
</span><span class='line'>Arial\ Bold\ Italic=arialbi.ttf
</span><span class='line'>Arial\ Italic=ariali.ttf
</span><span class='line'>Courier\ New=cour.ttf
</span><span class='line'>Courier\ New\ Bold=courbd.ttf
</span><span class='line'>Courier\ New\ Bold\ Italic=courbi.ttf
</span><span class='line'>Courier\ New\ Italic=couri.ttf
</span><span class='line'>Times\ New\ Roman=times.ttf
</span><span class='line'>Times\ New\ Roman\ Bold=timesbd.ttf
</span><span class='line'>Times\ New\ Roman\ Bold\ Italic=timesbi.ttf
</span><span class='line'>Times\ New\ Roman\ Italic=timesi.ttf
</span><span class='line'>OCRB=ob______.ttf
</span></code></pre></td></tr></table></div></figure>
<p>I added the last line, <code>OCRB=ob______.ttf</code>, following the pattern <code>FontFaceName=fontFileName.ttf</code>.</p>
<p>Note that spaces in the font name are escaped with backslashes, so those look like this <code>Font\ Face\ Name=fontFileName.ttf</code>.</p>
<p>Ok, save pd4fonts.properties when you’re done, zip the fonts directory up into fonts.zip, rename it to fonts.jar, copy it back where it came from in the /lib/ directory, overwriting … no wait! Don’t just overwrite the old fonts.jar. Keep a copy of it, just in case … replace the old fonts.jar with the new fonts.jar, change the owner/group permissions to match the old file, and then restart Lucee.</p>
<p>The name to use in your CSS for the font is the name you placed in the pd4fonts.properties file.</p>
<p>Of course, the above approach for Lucee ( 4.5 ) might certainly change in the future. But for now, it works like this.</p>
<p>A big thanks to <a href="http://blog.hnat.de/post.cfm/schriftarten-zu-railo-hinzufugen">Michael Hnat</a> for pointing me in the right direction regarding Lucee with his very helpful blog post.</p>
<h2>Images</h2>
<p>There is a logo image at the top of this PDF that was scaling up when rendered in Lucee in a way that caused it to be misplaced. The top left position was correct, but it was about 50% too big, pixelated, and overran other text. After a bunch of reading that indicated modifying the image print size or resolution would not help, I tried adding a css style declaration to the image that specified a size in mm, and it worked! Thanks to faxi05 for the suggestion.</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'><img src="logos/imageName.png" style="width:78mm; height:14mm" />
</span></code></pre></td></tr></table></div></figure>
<p>… and it’s cross compatible with ACF!</p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2015/06/16/cfml-queries-in-script/">CFML Queries in Script</a></h1>
<p class="meta">
<time class='entry-date' datetime='2015-06-16T18:39:54+02:00'><span class='date'><span class='date-month'>Jun</span> <span class='date-day'>16</span><span class='date-suffix'>th</span>, <span class='date-year'>2015</span></span> <span class='time'>6:39 pm</span></time>
| <a href="/blog/2015/06/16/cfml-queries-in-script/#disqus_thread"
data-disqus-identifier="http://dnando.github.io/blog/2015/06/16/cfml-queries-in-script/">Comments</a>
</p>
</header>
<div class="entry-content"><p>Recently, I needed to write a somewhat complex query with a conditional where clause. I resisted the urge to revert to the cfquery tag for this sort of thing, and came up with the following using queryExecute(), submitted as an example without explanation. This approach works on both ACF and Lucee.</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
<span class='line-number'>40</span>
<span class='line-number'>41</span>
<span class='line-number'>42</span>
<span class='line-number'>43</span>
<span class='line-number'>44</span>
<span class='line-number'>45</span>
<span class='line-number'>46</span>
<span class='line-number'>47</span>
<span class='line-number'>48</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>public query function findRawAudit( string entity, numeric userId, date dateFrom, date dateTo, numeric timeZoneOffset ) {
</span><span class='line'> var newLine = CHR(13) & CHR(10);
</span><span class='line'> var params = {};
</span><span class='line'> var sql = "
</span><span class='line'> select a.entity, a.entityId, a.timestamp, a.transaction, a.attribute, a.value as previousValue, u.name as username, null as currentValue, null as auditName, null as asql
</span><span class='line'> from Audit a inner join User u
</span><span class='line'> on a.userId = u.userId