Inside Out Outside In

FarCry Webtop: AJAX URL Caching

IE has this annoying habit of caching AJAX requests unless you make the URL unique on each request. The 4.x FarCry admin webtop uses the DataRequest.js (v 1.4) library for AJAX calls which has the caching problem. The fix is in easy one, just open up the library (Farcry\core\admin\includes\lib\DataRequestor.js) and insert the following two lines at line 164 in the getURL function;

var tsTimeStamp= new Date().getTime();
self.addArg(_GET,"tsTimeStamp",tsTimeStamp);

BlueDragon: Kudo's to NewAtlanta

I'm looking forward to the summer release of BlueDragon J2EE edition under GPL.  Currently I use the standard version of BlueDragon for one main reason, it's free.  I would have liked to use the enterprise version, but I just couldn't justify it when I'm only using it for this blog which is purely a labor of love and the site really doesn't generate any revenue, more of a money pit really, and the less I pour down the hole the better. 

When I was looking around for a place to host my blog, I looked at some the ColdFusion hosting partners.  Since I tinker quite a bit and didn't want to deal with any restrictions, a virtual server seemed the best solution.  The only problem with most virtual servers offered by hosting partners is that you have to put your own software on it, or pay a fairly hefty fee for ColdFusion.   In my configuration I'm paying the premium for windows hosting vs a linux virtual server. I'm comfortable with a fee range in the area of $60, or more precisely, I don't have to justify it budget wise.    Not having to pay for BlueDragon let me beef up some of the virtual server options.

While I did work for Allaire and Macromedia ages ago, any feeling of being a traitor has been diminished during the changing of the guard from Allaire to Macromedia to Adobe.   Being able to throw BlueDragon in as part of the solution enlarges the target customer base by bringing into the fold those customers who would balk at the $1299 price of a standard edition of ColdFusion, regardless of any other benefits that ColdFusion might have to offer.


Small opportunities are often the beginning of great enterprises.
Demosthenes (384 BC - 322 BC)

 

RegEx: Harvesting Email From Body Text

A quick snippet for harvesting emails from a text string;

<cfset searchTxt= "John.Doe@somecompany.com is an email and so is SaraJane@foo.net but foo@bar. is not">
<cfset reMailMatch = "([\._a-zA-Z0-9-]+@[_a-zA-Z0-9-]+\.[\._a-zA-Z0-9-]+)">

<cfset oPattern = createObject("java","java.util.regex.Pattern")> 

<cfset pattern = oPattern.compile(reMailMatch)>

<cfset oMatcher = pattern.matcher(searchTxt)>
<cfset emailList = "">
<cfloop condition="oMatcher.find()">
<cfset emailList = ListAppend(emailList,oMatcher.group())>
</cfloop>

<cfoutput>#emailList#</cfoutput>

CFCHART: Passing Additional Value in URL Other Than the 3 Standard Values

CFCHART documentation states that  $ITEMLABEL$, $VALUE$, and $SERIESLABEL$ can be passed in the url attribute.  Did you know you can also use $(colIndex), which will pass the (zero based ) column index of the item clicked. 



<cfchart 
      tipStyle
="mousedown"  title="Fruit"
       url
="pie.cfm?fruit_name=$ITEMLABEL$&COLINDEX=$(colIndex)"

      font
="arial"
      fontsize
=14
      fontBold
="yes"
      foregroundcolor
="##660066"
      show3D
="yes"
      chartheight
="400"
      chartwidth
="500"
      
>
      
      
<cfchartseries type="pie">
            
<cfchartdata item="Apple 1" value="25">
            
<cfchartdata item="Apple 2" value="25">
            
<cfchartdata item="Orange 1" value="25">
            
<cfchartdata item="Orange 2" value="25">
      
</cfchartseries>
      
                  
                  
</cfchart>

Flex 3 Builder Upgrades: Where's the Price Break if You Already Have Charting?

I'm a little disappointed that Adobe lumped the Flex Builder 2 Upgrade to Flex Builder 3 Professional with both the Flex Builder 2 and Flex Builder 2 with Charting.     Considering we purchased the Flex Builder with Charting in September of last year, having to pay the $299.00 to get charting in Flex 3 as opposed to the decently priced $99 upgrade is going to be a hard sell to management. 

Checking for HTML injection in all your comment fields.

When checking for html injection in your blog comments, unless you're moderating your comments, remember to check all the fields, not just the body and strip the html.  I was reading some old blog entries of some friends (cough* Kevin's, sorry bub!) and noticed quite a bit of spam in the comment titles.  The spammer had used a link the comment title.  Unfortunately, the link doesn't have a rel="nofollow" attribute either, so the blog is just contributing to the spammers ranking. 

Adobe Forums: Tweaking myForums to remember settings with GreaseMonkey

I usually try to hit the Adobe ColdFusion forums to provide answers every day and I've always wished that the MyForums would remember the select settings for the forum and how many entries to list.  So until Adobe tweaks the system to remember user settings, here's a FireFox GreaseMonkey script that will do the trick.   It's currently set to http://www.adobe.com/cfusion/webforums/* as the trigger. 

ColdFusion Verity OEM Command Line Tools

A recent post on the forums asked about creating a custom Thesaurus using the ColdFusion Verity K2 tools.  It seems that Adobe doesn't include the mksyd tool in their OEM license, but some OEM licenses do.  Like Adobe, Oracle is kind enough to provide evaluation/developer downloads which makes it a little easier to play around with the Verity K2 engine on different platorms.. 

Here's a quick comparison between the command line tools included with the Oracle Content Server Verity Integration - VDK6 (optional module) and the tools included with CF.

 

Command Description Oracle CF
browse.exe

Lists the field names and values stored in a
collection's documents table, one partition at a time.

X X
codeconv.exe Converts character sets for Bulk Insert Files
(BIFs) and style files.
X
delbyqry.exe Deletes documents from a collection,
using a query as input.
X
dicheck.exe X
didump.exe Produces a word list for a collection,
one partition at a time.
X X
k2admin.exe  ColdFusion k2Admin X
k2index.exe  ColdFusion K2Index X
extract.exe

Uses a specification file, extracts fields
from a collection, and then stores
them in a Bulk Insert File (BIF).

X
ezstream.exe Tests documents to determine
if they can be viewed.
X
fscrawl.exe Crawls a file system directory, and
then creates a Bulk Insert File (BIF)
X
genvlvdk.exe update your existing license key X
langid.exe Detects the language content of a document. X
k2server.exe ColdFusion K2 server X
licfile.exe X
merge.exe Enables you to merge and
split collections that share the same styleset.
X X
mkenc.exe Generates encrytion keys for Topic Sets. X
mklrc.exe Utility for LRC based classification. X
mkpi.exe Creates parametric indexes
controlled by an outline file
X X
mksyd.exe Creates a custom thesaurus file. X
mktm.exe Creates and maintains thematic mapping files. X
mktopics.exe Creates topic sets using topic definitions
contained in an outline
X
mkvdk.exe Create and maintain collectio X X
pdfoop.exe Filters PDF X X
rck2.exe  ColdFusion, search a collection from a
command prompt
X
rcodk.exe Tests indexes created using
Organization Developer’s Kit (ODK)
X
rcvdk.exe Searches collections. X X
regsvr32.exe Registers vIndex.dll X
repair.exe Repairs collections. X
savecred.exe Creates crendentials file X
testqp.exe Tests a specified query parser. X

 

Stupid MS Access Tricks

You've probably read that MS Access doesn't support stored procedures.  The real answer that it does, but not as you would expect to use it in ColdFusion.  When you issue a create procedure such as below;

Note: Below code was run on CFMX 7 with the cfbookclub MSAccess db.

<cfquery datasource="cfbookclub" >
CREATE PROCEDURE spByAuthor
AS
SELECT AUTHORS.FIRSTNAME, AUTHORS.LASTNAME, BOOKS.BOOKID, BOOKS.TITLE
FROM AUTHORS INNER JOIN BOOKS ON AUTHORS.AUTHORID=BOOKS.AUTHORID
WHERE AUTHORS.LASTNAME LIKE [@authorlast];
</cfquery>

You end up with a saved query.  With ColdFusion you can call queries in Access just as you would a table.  The problem occurs when the saved query has a parameter.  The standard cfstoredproc tag has a problem calling the stored procedure/query in Access and will result in an error.

The way to call the saved query with a param is as follows;

<cfquery name="qryBooks" datasource="cfbookclub" >
        EXECUTE spByAuthor <cfqueryparam cfsqltype="cf_sql_varchar" value="M%">
</cfquery>

File Upload Progress bar using JSP's and Session Beans

 ColdFusion 8 supports CFFILE large file uploads, due to a change in the default behavior of the GetHttpRequestData()  function.  Unfortunately, CF8 still doesn't provide any solution for a progress bar.  One solution I've found is to use a combination of JSP's and session beans and jQuery to provide not only large file uploads which works on CF 8 as well as CF 7, but also a progress. bar.  JavaZoom's uploadBean has a nice API and the download package includes some examples.  Now a couple of assumptions.  Since the downloads include fairly straightforward examples, I'm not going to go to deep into the code and will assume that if you are going to go down this path, that you will know something of JSP's, and for customization, a little bean knowledge along with basic jQuery.

The javazoom downloads have everything you need including the necessary jar files and examples.  put the jar files in  the cfusion web-inf/lib directory.  The easiest way to get up and running is to modify the LargeUpload.jsp that is included in the example to match your look and feel.    Just place the jsp in your application web folder.  The Progress Status addon provides the current status of the upload via a simple pop up that uses a meta-refresh which uses a session bean to generates the output for the current upload and total values.    The status session bean is added as a listener to the uploadBean on the upload form.  .

The examples don't include any authentication, so I would suggest creating an authentication bean based on your requirements.  In my case, I chose IIS authentication, along with a database ACL, where a folder id was used and checked against the ACL and the currently logged on user.

Now the jQuery bit, which provides the progress bar instead of a popup window.  For this, you'll need the progress bar plugin from digitalbush.

First, create an ajaxStatus.jsp that will use the progress session bean and generate the data used by jQuery.
-------------------------------------------------------------------------------------------------------------------------
ajaxStatus.jsp
<%@ page language="java"  %>
<%@ page errorPage="ExceptionHandler.jsp" %>
<jsp:useBean id="upListener" scope="session" class="sample.Progress"/>
<%= upListener.getUploadedRatio() %>|<%= upListener.getUploadedKBLength() %>|<%= upListener.getTotalLength() %>
------------------------------------------------------------------------------------------------------------------------

Then add the necessary html scripts, css and includes for jQuery and the jquery.Progressbar files  to the modified LargeUpload.jsp
------------------------------------------------------------------------------------------------------------------------

<script>

function formatFileSize(num){
    
        //return num;
        
        var fNum = 0;
        var type = "b"
        if ((num > 1024) && (num < 1048576)) {
            fNum =  num / 1024;
            type = "Kb"
        } else if (num > 1048576) {
            fNum = num/1048576;
            type = "Mb"
        } else {
            fNum = num;
        }
        
        var nf = new NumberFormat(fNum);
        nf.setPlaces(3);
        nf.setSeparators(true);
        var num = nf.toFormatted();
        
        return num + " " + type;
        
    }


function showStatus(data){
    var progress = data.split("|");

    if(progress[0] != "null" && parseInt(progress[0]) != -1){
        $("#progressbar").reportprogress(parseInt(progress[0]));
        var bUp = formatFileSize((parseInt(progress[1]) * 1000));
        var bTotal = formatFileSize(parseInt(progress[2]));
        $("#progressInfo").html(bUp + " / " + bTotal);
        // Not going to worry about clearing the interval since the
        // page is going to refresh when the upload is done.
    }
}
    

function update(){
    $.get("ajaxStatus.jsp",showStatus);
}
    

function submitValidation(){
    // other validation routines

     handle=setInterval("update()",100);

    document.yourForm.submit();
}

$(document).ready(function() {
    

    $("#YourSubmitButton").click(submitValidation);

}
</script>

<!--- HTML section that will display the progressbar and info --->
 <div id="progressbar"></div>
 <div id="progressInfo">KB</div>

More Entries