0

我正在尝试创建一个带有 3 个选择框的表单,这些框绑定到 cfc(三重相关 cfselect)。如果我删除 Application.cfc,代码运行得很好,选择框会提供我需要的数据。但是,当我添加具有 cflogin 功能的 Application.cfc 时,该功能需要用户登录才能使用任何页面,而不是我的三重相关选择框不再起作用。选择框只是不会从函数中的查询中给出任何数据。它仍然连接到功能页面,因为当我在 cfselect 的绑定上更改名称时,它会让我知道组件中不存在该功能。我不确定我必须做什么才能使三重相关的 cfselect 与 cflogin 一起工作。
我正在使用 ColdFusion 10
我非常感谢任何建议。
谢谢,尼瓦

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

<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

  <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

  <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>
4

1 回答 1

0

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

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

   </cfoutput> 

因此,查看 ajax 响应,注销表单被放置在信息中,因此选择框没有解析值。我在 Application.cfc 中删除了这个部分,页面运行得很好。非常感谢您的帮助!^_^

于 2013-10-25T20:25:44.120 回答