首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当我启用Application.cfc时,cfselect绑定在cfc中无法工作。

当我启用Application.cfc时,cfselect绑定在cfc中无法工作。
EN

Stack Overflow用户
提问于 2013-10-24 19:20:36
回答 1查看 750关注 0票数 0

我正在尝试创建一个包含三个选择框的表单,这些复选框被绑定到一个cfc (三重相关的cfselect)。如果删除Application.cfc,代码运行良好,复选框将提供我所需的数据。但是,当我添加具有cflogin功能的Application.cfc时,它要求用户在能够使用比我的三重相关复选框更多的页面之前登录。选择框不提供函数中查询中的任何数据。它仍然连接到函数页,因为当我更改cfselect绑定上的名称时,它会让我知道组件中不存在该函数。我不知道我要做什么,使三重相关的cfselect与cflogin工作到位。

我使用的是ColdFusion 10

我真的很感谢你的建议。

谢谢你,妮娃

我添加了代码:这是表单上的代码

代码语言:javascript
复制
<tr valign="top">  
    <td style="color:DarkSeaGreen; font-weight:bold; width=100">Product Type:</td>
    <td width="200">
    <cfselect name="Selproducttype" bind="cfc:groupfnc.getproducttypeid()"
        display="description" value="producttypeid" BindOnLoad="true"/></td></tr>
<tr valign="top">  
    <td style="color:DarkSeaGreen; font-weight:bold; width=100">Vendor:</td>
    <td width="200">
    <cfselect name="Selvendor" bind="cfc:groupfnc.getven({Selproducttype})"
        display="fullname" value="vendorid" BindOnLoad="true"/></td></tr>   

<tr valign="top">  
    <td style="color:DarkSeaGreen; font-weight:bold; width=100">Product:</td>
    <td width="200">

<cfselect name="Selprod" bind="cfc:groupfnc.getprod({Selvendor})"
        display="fullname" value="productid" BindOnLoad="true" /></td></tr>
<tr valign="top">  
    <td style="color:DarkSeaGreen; font-weight:bold; width=100">Sub Product:</td>
    <td width="200">
    <cfselect name="Selsubprod" bind="cfc:groupfnc.Getsub({Selprod})"
        display="fullname" value="productsubid" /></td></tr>

组件代码: groupfnc.cfc

代码语言:javascript
复制
  <cffunction name="getproducttypeid" access="remote" output="false" returntype="query">
<cfquery name="listproducttype" datasource="xxxxxx">
    Select distinct producttypeid, (Case when producttypeid = '101' then 'Hotel' 
                         when producttypeid='201' then 'optionalTour' 
                         when producttypeid = '301' then 'Transporation' 
                         when producttypeid = '501' then 'MISC'
                         when producttypeid = '601' then 'OTH' end) as description
    From products
</cfquery>
<cfreturn listproducttype />
</cffunction>

<cffunction name="getven" access="remote" output="false" returntype="Query">
    <cfargument name="Selproducttype" type="any" required="true">
    <cfif ARGUMENTS.Selproducttype EQ "">
    <cfset ARGUMENTS.Selproducttype = '0'>
    </cfif>
    <cfquery name="listven" datasource="xxxxxx">
    SELECT distinct vendors.fullname, vendors.vendorid 
    from vendors, products
    where products.vendorid= vendors.vendorid
    and  products.producttypeid = #ARGUMENTS.Selproducttype#
    ORDER BY fullname
    </cfquery>
    <cfreturn listven />
</cffunction>


<cffunction name="getprod" access="remote" output="false" returntype="Query">
    <cfargument name="Selvendor" type="any" required="true">
    <cfif ARGUMENTS.Selvendor EQ "">
    <cfset ARGUMENTS.Selvendor = '0'>
    </cfif>
    <cfquery name="Lstprod" datasource="xxxxxx">
    Select productid, fullname from products
    where vendorid = #ARGUMENTS.Selvendor#
    order by fullname
    </cfquery>
    <!---</cfif>--->
    <cfreturn Lstprod />
</cffunction>    
<cffunction name="Getsub" access="remote" output="false" returntype="Query">
    <cfargument name="Selprod" type="any" required="true">
    <cfif ARGUMENTS.Selprod EQ "">
    <cfset ARGUMENTS.Selprod = '0'>
    </cfif>
    <cfquery name="Lstsubprod" datasource="xxxxxx">
    Select productsubid, fullname from productsubs
    where productid = #ARGUMENTS.Selprod#
    order by fullname
    </cfquery>
    <!---</cfif>--->
    <cfreturn Lstsubprod />
</cffunction>

这是我的application.cfc

代码语言:javascript
复制
  <cfcomponent> 
   <cfset This.name = "Orders"> 
   <cfset This.Sessionmanagement="True"> 
   <cfset This.loginstorage="session"> 

     <cffunction name="OnRequestStart"> 

       <cfargument name = "request" required="true"/> 
         <cfif IsDefined("Form.logout")> 
          <cflogout> 
        </cfif> 

    <cflogin> 
       <cfif NOT IsDefined("cflogin")> 
         <cfinclude template="loginform.cfm">

          <cfabort> 
       <cfelse> 
        <cfif cflogin.name IS "" OR cflogin.password IS ""> 

            <cfoutput> 
                <h2>You must enter text in both the User Name and Password fields. 
                </h2> 
            </cfoutput> 
              <cfinclude template="loginform.cfm">
            <cfabort> 
        <cfelse> 
            <cfquery name="loginQuery" dataSource="xxxxxx"> 
            SELECT userid, roles 
            FROM logininfo 
            WHERE 
                userid = '#cflogin.name#' 
                AND upassword = '#cflogin.password#' 
            </cfquery> 
            <cfif loginQuery.roles NEQ ""> 
                <cfloginuser name="#cflogin.name#" Password = "#cflogin.password#" 
                    roles="#loginQuery.roles#"> 
            <cfelse> 


                <cfoutput>
                    <H2>Your login information is not valid.<br> 
                    Please Try again</H2> 
                </cfoutput>     
               <cfinclude template="loginform.cfm">  
                <cfabort> 
            </cfif> 
        </cfif>     
      </cfif> 
  </cflogin> 

   <cfif GetAuthUser() NEQ ""> 
     <cfoutput> 

            <form action="securitytest.cfm" method="Post"> 
            <input type="submit" Name="Logout" value="Logout"> 
        </form> 

       </cfoutput> 
  </cfif> 

 </cffunction> 
</cfcomponent>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-10-25 20:25:44

我发现了问题。因为在我的Application.cfc中有这样的部分:

代码语言:javascript
复制
        <form action="securitytest.cfm" method="Post"> 
        <input type="submit" Name="Logout" value="Logout"> 
    </form> 

   </cfoutput> 

因此,查看ajax响应,登录表单被放置在infornt中,因此复选框没有解析值,我删除了这个partin,Application.cfc,页面运行得很好。非常感谢你的帮助!^_^

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19574728

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档