Quantcast
Channel: Adobe Community : Popular Discussions - Using Flash Builder
Viewing all articles
Browse latest Browse all 70427

How to check for empty get results set (cf datasource)

$
0
0

I am using coldfusion for my dataservice (FLOWTESTService1). This code does 2 things - 1. passes URL query string to cf data service, and 2. queries cf data service via a button and textbox.

The problem is that I need to check for empty results set when the cf data source gets queried.

That is what I am trying to accomplish here:  if (getFLOWTESTResult != null && getFLOWTESTResult.lastResult != null){
                    Alert.show("No flow test data for this fire hydrant.");
                }else {

This works but it fires the Alert.show("No flow....  all the time, even when I know there are valid records that should be returned.


Any help is much appreciated. Thanks.

 

Will

 

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:flowtestservice1="services.flowtestservice1.*" xmlns:valueObjects="valueObjects.*"
                initialize="init()" width="1066" pageTitle="City of Durham - Fire Hydrant Flow Test Card">
    <fx:Style source="FireFlow2.css"/>
    <fx:Script>
        <![CDATA[
            import mx.controls.Alert;
            private var PRESSID:String = "03707";
            private function init(): void
            {
                if (getFLOWTESTResult != null && getFLOWTESTResult.lastResult != null){
                    Alert.show("No flow test data for this fire hydrant.");
                }else {
            PRESSID = this.parameters.PRESSID;
            getFLOWTESTResult.token = fLOWTESTService1.getFLOWTEST(PRESSID);
                }
            }
           
            protected function button_clickHandler(event:MouseEvent):void
            {
                //if (fLOWTESTService1 != null) {
                //Alert.show("No flow test data for this fire hydrant.");
                //}else {
                getFLOWTESTResult.token = fLOWTESTService1.getFLOWTEST(pRESSIDTextInput.text);
                //}
            }
           
            private function dateFormat(item:Object, column:DataGridColumn):String{
                return dateFormatter.format(item [column.dataField]);
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <flowtestservice1:FLOWTESTService1 id="fLOWTESTService1" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
        <s:CallResponder id="getFLOWTESTResult" result="customDatatype = getFLOWTESTResult.lastResult[0] as CustomDatatype"/>
        <valueObjects:CustomDatatype id="customDatatype"/>
        <mx:DateFormatter id="dateFormatter"
            formatString="MM-DD-YYY"/>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <mx:Form y="46" defaultButton="{button}" borderAlpha="0.5" cornerRadius="0" dropShadowVisible="true" borderColor="#A24E4E" x="258">
        <mx:FormItem label="Hydrant ID:">
            <s:TextInput id="pRESSIDTextInput"/>
        </mx:FormItem>
        <s:Button label="Get FLOW TEST" id="button" click="button_clickHandler(event)"/>
        <mx:Form borderAlpha="0.5">
            <mx:FormHeading label="Results:"/>
            <mx:FormItem label="Hydrant ID:">
                <s:Label id="pRESSIDLabel" text="{customDatatype.PRESSID}"/>
            </mx:FormItem>
            <mx:FormItem label="Date:">
                <mx:DateField enabled="false" id="dATEDateField" selectedDate="{customDatatype.DATE}"/>
            </mx:FormItem>
            <mx:FormItem label="Time:" contentBackgroundAlpha="1.0">
                <s:Label id="tIMELabel" text="{customDatatype.TIME}"/>
            </mx:FormItem>
            <mx:FormItem label="Location 1:">
                <s:Label id="lOC1Label" text="{customDatatype.LOC1}"/>
            </mx:FormItem>
            <mx:FormItem label="Location 2:">
                <s:Label id="lOC2Label" text="{customDatatype.LOC2}"/>
            </mx:FormItem>
            <mx:FormItem label="Flow (gpm):">
                <s:Label id="fLOWLabel" text="{customDatatype.FLOW}"/>
            </mx:FormItem>
            <mx:FormItem label="Static (psi):">
                <s:Label id="sTATICLabel" text="{customDatatype.STATIC}"/>
            </mx:FormItem>
            <mx:FormItem label="Residual (psi):">
                <s:Label id="rESIDUALLabel" text="{customDatatype.RESIDUAL}"/>
            </mx:FormItem>
            <mx:FormItem label="PRESLOC">
                <s:Label id="pRESLOCLabel" text="{customDatatype.PRESLOC}"/>
            </mx:FormItem>
            <mx:FormItem label="Q20 (gpm):">
                <s:Label id="q20Label" text="{customDatatype.Q20}"/>
            </mx:FormItem>
            <mx:FormItem label="FLOWID">
                <s:Label id="fLOWIDLabel" text="{customDatatype.FLOWID}"/>
            </mx:FormItem>
            <mx:FormItem label="FLOWLOC">
                <s:Label id="fLOWLOCLabel" text="{customDatatype.FLOWLOC}"/>
            </mx:FormItem>
           
        </mx:Form>
    </mx:Form>
    <mx:DataGrid x="72" y="549" id="dataGrid" dataProvider="{getFLOWTESTResult.lastResult}" width="904" height="160" editable="false" variableRowHeight="true">
        <mx:columns>
            <mx:DataGridColumn headerText="PRESSID" dataField="PRESSID" wordWrap="false"/>
            <mx:DataGridColumn headerText="Date" dataField="DATE" labelFunction="dateFormat"/>
            <mx:DataGridColumn headerText="TIME" dataField="TIME"/>
            <mx:DataGridColumn headerText="LOC1" dataField="LOC1" wordWrap="true"/>
            <mx:DataGridColumn headerText="LOC2" dataField="LOC2" wordWrap="true"/>
            <mx:DataGridColumn headerText="FLOW" dataField="FLOW"/>
            <mx:DataGridColumn headerText="STATIC" dataField="STATIC"/>
            <mx:DataGridColumn headerText="RESIDUAL" dataField="RESIDUAL"/>
            <mx:DataGridColumn headerText="PRESLOC" dataField="PRESLOC" wordWrap="true"/>
            <mx:DataGridColumn headerText="Q20" dataField="Q20"/>
            <mx:DataGridColumn headerText="FLOWID" dataField="FLOWID"/>
            <mx:DataGridColumn headerText="FLOWLOC" dataField="FLOWLOC" wordWrap="true"/>
        </mx:columns>
    </mx:DataGrid>
    <mx:ColumnChart x="594" y="117" id="columnchart1" dataProvider="{getFLOWTESTResult.lastResult}" showDataTips="true" width="431" height="373">
        <mx:series>
            <mx:ColumnSeries displayName="Flow" yField="FLOW" id="columnSeries"/>
            <mx:ColumnSeries id="columnSeries4" displayName="Q20" yField="Q20"/>
        </mx:series>
        <mx:horizontalAxis>
            <mx:CategoryAxis id="categoryAxis" categoryField="DATE"/>
        </mx:horizontalAxis>
    </mx:ColumnChart>
    <mx:Legend dataProvider="{columnchart1}"/>
    <mx:Image x="103" y="96" source="http://localhost:8500/FireFlow2-debug/durhamlogo.PNG"/>
    <s:RichText x="72" y="261" text="*This information represents flows and pressures at one specefic time. These parameters constantly fluctuate. Designers should use appropriate factors of sfety when using this information for design purposes." width="151" height="162" verticalAlign="middle" textAlign="center"/>
    <s:RichText x="171" y="11" text="Fire Hydrant Flow Test Card" fontSize="24" verticalAlign="middle" textAlign="center" fontWeight="bold"/>
    <s:Label x="72" y="529" text="Flow Test History:" fontWeight="bold" fontSize="14"/>
</s:Application>


Viewing all articles
Browse latest Browse all 70427

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>