Skip to main content
Participating Frequently
January 14, 2011
Question

cfselect bind returns nothing

  • January 14, 2011
  • 3 replies
  • 6579 views

Hi,

I have a simple form with 2 selects. The 2nd is bound to the 1st. Issue seems to be that there is no response from the CFC call (I'm using the url parameter ?cfdebug to see this).

My co-worker & I have almost gone blind trying to see what's wrong with this code!

Any help is greatly appreciated!

Form code:

<cfajaximport tags="cfform">


<p>   
    <cfform action="rptLegend.cfm" name="legend" id="legend" method="post">
    <table align="center">
        <tr>
            <td>Choose a Building:</td> 
            <td><cfselect name="BuildingID"
                        size="1"
                        title="Choose the Building"
                        id="inputSelectMultiWide"
                        onfocus="this.style.background='##dddd66';"
                        onBlur="javascript: this.style.background='##ffffff';" 
                        onkeypress="javascript: if(event.keyCode==13) return false;"
                        query="Application.qBldgs"
                        queryposition="below"
                        value="BuildingID"
                        display="FullName">                       
                    <option value="">- Select -</option>
                </cfselect>
            </td>
        </tr>
        <tr>
            <td>Choose a Unit:</td> 
            <td><cfselect name="UnitNum"
                        size="1"
                        title="Choose the Unit"
                        id="inputSelect"
                        onfocus="this.style.background='##dddd66';"
                        onBlur="javascript: this.style.background='##ffffff';" 
                        onkeypress="javascript: if(event.keyCode==13) return false;"
                        bind="cfc:#Application.cfcPath#.Panels.GetBindUnit({BuildingID})"
                        display="UnitNum"
                        value="UnitNum">                       
                    <option value="">- Select -</option>                       
                </cfselect>
            </td>
        </tr>
    <tr>
        <td colspan="2" height="30">
            <p align="center">
            <button class="btnSubmit" type="button" value="Cancel" onclick="javascript: history.go(-1);"> Cancel </button> 
            <button class="btnSubmit" type="submit" value="d" name="submit" onclick="javascript: document.legend.submit;"> Get Square D Type Legend </button> 
            <button class="btnSubmit" type="submit" value="n" name="submit" onclick="javascript: document.legend.submit;"> Get Narrow Type Legend </button>
            </p>
        </td>
    </tr>
    </table>

</cfform>

cfc function:

<cfcomponent displayname="Panel functions" hint="Panel functions" output="false">

    <cffunction name="GetBindUnit" access="remote" output="true" returntype="query">
        <cfargument name="BuildingID" type="string" required="true">
       
        <!--- Define variables --->
        <cfset var result="">
        <cfset var temp="">
       
        <!--- get all units in Bldg to populate Unit select box --->
        <cfquery name="result" datasource="#Application.dSource#">
            SELECT UnitNum
            FROM Panels
            WHERE BuildingID LIKE <cfqueryparam value="#Arguments.BuildingID#" cfsqltype="cf_sql_varchar" maxlength="10">
        </cfquery>   
       
        <!--- make sure we return at least 1 row --->
        <cfif #result.recordcount# EQ 0>
            <cfset temp=QueryAddRow(result,1)>
            <cfset temp=Querysetcell(result,"UnitNum","NONE AVAILABLE")>
        </cfif>
       
        <cfreturn result />
    </cffunction>

</cfcomponent>

http://137.229.22.51/uaf/PanelMan/includes/inc_legend.cfm?cfdebug    -shows the empty response from the cfc call

Hope more eyes can help!

Thanks

    This topic has been closed for replies.

    3 replies

    Participating Frequently
    June 2, 2011

    Try this.  Create an empty application.cfc file and place it in the same folder as your other cfc files.  That worked for us after countless hours of not getting results from binding to cfcs.

    BKBK
    Community Expert
    Community Expert
    January 20, 2011

    I think I've spotted the cause of the problem. Use a % symbol in the where-clause. Something like

    <cfset var search_building_id = '%' & trim(arguments.BuildingID) & '%'>

    <cfquery>

    ...

    ...

    WHERE BuildingID LIKE <cfqueryparam value="#search_building_id#" cfsqltype="cf_sql_varchar" maxlength="10">
    </cfquery>

    BKBK
    Community Expert
    Community Expert
    January 16, 2011

    The value of Application.cfcPath is probably of the form a/b/c, whereas the bind expression requires a.b.c

    vntabbAuthor
    Participating Frequently
    January 18, 2011

    Actually, the path is a.b.c and I use it often on other pages to call functions.

    BKBK
    Community Expert
    Community Expert
    January 19, 2011

    Use the following test code. Does the first cfselect get populated?

    <cfselect name="BuildingID"                      
        query="Application.qBldgs"
        queryposition="below"
        value="BuildingID"
        display="FullName">                      
        <option value="">- Select -</option>
    </cfselect>
    <cfselect name="UnitNum"
        bind="cfc:#Application.cfcPath#.Panels.GetBindUnit({BuildingID})"
        display="UnitNum"
        value="UnitNum">
        queryposition="below"                     
        <option value="">- Select -</option>                      
    </cfselect>