Using Flash Forms Inside Of CF 8 Ajax Containers

Posted By : todd sharp Posted At : August 20, 2007 3:58 PM Posted In: Ajax, Flash Forms, ColdFusion

12

A comment on Ray's post about cfgrid renderers today asked why a Flash form grid would not load inside of a cfwindow. I mentioned the reason why Flash Forms/Flex SWF's won't load without modifications previous post, but wanted to throw out a reminder in case folks may have missed it.

Exporting A Flex DataGrid To Excel

Posted By : todd sharp Posted At : January 24, 2007 12:36 PM Posted In: Flex, Flash Forms, ColdFusion

7

This is easily found via Google, but it's pretty cool nonetheless. There's a cool example up on CFLEX.NET that shows an implementation of exporting the contents of a Flex DataGrid to Excel. Essentially the script loops over the grid and creates an HTML table from the contents. The script then sets that table (in the form of a string) to the users clipboard and calls a JS function in the calling page to open an Excel workbook and paste the contents of the system clipboard to the new workbook (or fails to an alert which tells the user their clipboard is set). This implementation is specific to Flex 1.5 I believe - but there is a comment posted to the example with a 2.0 version. I've used this technique successfully on smaller grids - anything too large will crash Flash Player.

My most recent use of this was on a grid that was guaranteed to contain small results (no more then 50 rows, 20 cols). I did make a minor change to the script to have the doCopy() function return the string rather then set it to the clipboard. My next step was to pass the string via getURL() to a ColdFusion template which served the string up in Excel with CFCONTENT.

If you're new to Flex you should definitely keep your eye on CFLEX.net - it's a really good resource run by Tariq Ahmed.

Fixing The ComboBox Cell Renderer Weirdness

Posted By : todd sharp Posted At : October 29, 2006 7:25 AM Posted In: Flash Forms, ColdFusion

1

Last week I posted an issue with some cell renderer weirdness when rows were added to the grid and the grid was scrolled. Apparently the grid actually "recycles" the renderer, thus reusing whatever selectedItem was in the same spot in the grid when scrolled. The fix was actually quite simple, but I thought I would share it for anyone experiencing the same problem.

Here is the AS file for the renderer. For the complete example, see the related posts below.

import mx.core.UIComponent
import mx.controls.ComboBox

class ComboBoxCellNew extends UIComponent
{
    var combo : MovieClip;
    var owner : MovieClip;    
    var listOwner : MovieClip;
    var getCellIndex : Function;                 
    var getDataLabel : Function;                     
    function ComboBoxCellRenderer()
    {
    }

    function createChildren(Void) : Void
    {        
        //Creates a ComboBox object and listen to changes

combo = createObject("ComboBox", "Combo", 0, {styleName:this, owner:this});
        combo.addEventListener("change", this);
        combo.labelField = "priority";
        combo.dataProvider = _global.COMBOBOX_DATA_PROVIDER;
        size();
    }

    // note that setSize is implemented by UIComponent and calls size(), after setting
// __width and __height
    
function size(Void) : Void
    {
        
     var h = __height;
var w = __width;
combo.setSize(w - 2, Math.max(h, listOwner.rowHeight - 2));
        
    }

public function setValue(str:String, item:Object, sel:Boolean) : Void
    {
        /* Sets the ComboBox to the correspoinding cell data from the list owner's data provider if the cell data matches
        with any items available for the ComboBox. */

        
        var drawCombo:Boolean = true;
        if (item[getDataLabel()]!=undefined)
        {
            /* For each item's data in the ComboBox, verify if it matches
            the assigned data for the cell this ComboBox is in.
            Set the selectedIndex of the ComboBox to what matches. */

            for(var i:Number = 0; i < combo.length; i++)
            {
                if( combo.getItemAt(i).priority == item[getDataLabel()] )
                {
                    combo.selectedIndex = i;
                    break;
                }
                if ( i == combo.length - 1 )
                {
                //****THE FIX*** if the combobox has no length (on an insert) - set the selected index to 0 (the first item)
                    combo.selectedIndex = 0;
                }
            }
        }
        else
        {
            // There was no data, set the combobox to blank
            combo.selectedIndex = 0;
        }
        
        combo._visible = drawCombo;
    }

    function getPreferredHeight(Void) : Number
    {
        return owner.__height;
    }

    function getPreferredWidth(Void) : Number
    {
        return owner.__width;
    }
    // This re-build the dataProvider, the selected item
    // as the first in the array
    function reorder(datos:Array, choice:String):Array {
        var index:Number = 0
        var newArray = new Array()
        for(var i=0; i<datos.length; i++){        
            if(datos[i].label!=choice){
                index++
                newArray[index] = datos[i]
            } else newArray[0] = datos[i]
        }    
        return newArray
    }


    
    public function change()
    {
        // Handler for the ComboBox change event.
        
        // Set the listOwner's data to the currently selected item's data of the combo box.
        listOwner.dataProvider.editField(getCellIndex().itemIndex, getDataLabel(), combo.selectedItem.priority);    
        listOwner.selectedIndex = getCellIndex().itemIndex;
    }

}

Flash Form Cell Renderer Weirdness

Posted By : todd sharp Posted At : October 24, 2006 8:29 AM Posted In: Flash Forms, ColdFusion

4

I recently had to revisit my Flash Form combobox cell renderer examples to use the technique in a project that I am working on and found a very weird behavior that I'm hoping someone can help me figure out. Here is what's happening: When using a custom cell renderer in conjunction with an editable grid that allows row inserts, when the rows extend beyond the visible height of the grid, the combobox renderers begin to act very weird. Go to the example below and add about 15-20 rows and you'll see what I mean. After adding the rows, scroll up and down in the grid and things will just keep changing. Anyone know what's up? I am a little concerned that this is one of the drawbacks to hacking up this solution, but there really is no difference in this technique than techniques employed in Flex (which is really what Flash Forms are).

Example

Dumping Flash Form Data

Posted By : todd sharp Posted At : October 23, 2006 2:46 PM Posted In: Flash Forms, ColdFusion

0

This has been around for awhile, but if you haven't seen it you should definitely check it out if you do extensive work with Flash Forms. The guys over at newsight have a Flex trace panel, and this post shows how to use it with Flash Forms. It's definitely an invaluable tool!

Flash Form Theme Color Gotcha

Posted By : todd sharp Posted At : September 28, 2006 2:40 PM Posted In: Flash Forms, ColdFusion

1

Scott Stroz posted a few days ago about a cool way to customize the 'skin' color of a flash form. I mentioned in the comments that I had experienced some weirdness with datagrids not obeying the themeColor. Scott mentioned that his datagrids did obey the new themeColor, so I did a quick experiment. I found out that by setting the themeColor as an inline style using Scott's method will properly style the grid, but using formatting the way that I was using setStyle in Actionscript is what caused the grid weirdness.

Scott's Method (The Good Way)

<cfform format="flash" style="themeColor:##FF6666;">
    <cfinput type="text" name="foo" label="foo">
    
    <cfgrid name="fooGrid">
        <cfgridcolumn name="fooCol"/>
        <cfgridrow data="fooData"/>
    </cfgrid>
</cfform>

My Method (The Bad Way)

<cfform format="flash" onload="a();">
    <cfformitem type="script">
    function a(){
    _global.styles.Form.setStyle("themeColor", 0xFF6666);
    }
    </cfformitem>
    <cfinput type="text" name="foo" label="foo">
    
    <cfgrid name="fooGrid">
        <cfgridcolumn name="fooCol"/>
        <cfgridrow data="fooData"/>
    </cfgrid>
</cfform>

picViewer 1.1 - Now with RSS

Posted By : todd sharp Posted At : August 22, 2006 7:30 AM Posted In: picViewer, Flash Forms

0

picViewer has been updated to include RSS feeds. Now any instance that is not password protected allows your family and friends to subscribe to your pics via their favorite RSS reader (they will receive the 25 most recent pics as individual 'posts' in the feed). Also included in this release are some minor clean ups to the cfc.

Download

View Demo

picViewer 1.0.2

Posted By : todd sharp Posted At : August 16, 2006 9:04 AM Posted In: picViewer, Flash Forms, ColdFusion

0

An extremely minor update, really no need to download but I wanted to put the new zip up for anyone downloading picViewer in the future.

This release removes the dynamic application naming. It seemed to have been causing more problems than anything, so I rolled it back to a manual change. If you are going to run multiple instances of picViewer on the same server, please manually change the application name to a unique name in the application.cfc file to avoid conflicts.

Download

P.S. I'm going to upgrade my blog (again) when the next release of blogcfc comes out. When I do, I'll try to get a project page up.

CFGRID Date Display Issues

Posted By : todd sharp Posted At : August 11, 2006 9:16 AM Posted In: Flash Forms, ActionScript, ColdFusion

2

I got into a discussion today with someone on an old thread on Ray Camden's blog who was having issues with the way his dates were being displayed in a cfgrid. The problem he was having was that he would choose a date in a datefield, then submit the form and update the database with the date - For example:

Actionscript Business Day Add Function

Posted By : todd sharp Posted At : August 11, 2006 5:56 AM Posted In: Flash Forms, ActionScript, ColdFusion

2

One of my coworkers has been working on a project tracking tool and had a need to automatically calculate some dates based on the selected items and other dates (such as due date). I found this function over on Jeff Tapper's blog, but the function needed to add (and subtract) business days, not just calendar days. As a result I threw together another script to work in conjuction with Jeff's script to make it work for business days. There's nothing pretty about this code. I've been on conference calls for 6-7 hours a day for three weeks, so trust me - this one has little thought put into it. But it works - and with a little work it could be cleaned up.

View an Example

The source for the example is attached to this post if you'd like to download.

Enjoy & Happy Friday!