我正在尝试创建一个包含3个选择框的表单,这些框绑定到cfc(三重相关的cfselect)。如果我删除了Application.cfc,代码运行得很好,选择框会提供我需要的数据。但是,当我添加具有cflogin功能的Application.cfc时,该功能要求用户在能够使用任何页面之前登录,而不是我的三重相关选择框不再起作用。选择框只是不会从函数中的查询中提供任何数据。它仍然连接到函数页面,因为当我在cfselect的绑定上更改名称时,它会让我知道组件中不存在该函数。我不知道我需要做些什么来使三重相关的cfselect与cflogin一起使用。
我正在使用ColdFusion 10
我非常感谢任何建议。
谢谢,Niva
我添加了代码: 这是表单上的代码
<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>
答案 0 :(得分:0)
我发现了问题。因为在我的Application.cfc中有这个部分:
<form action="securitytest.cfm" method="Post">
<input type="submit" Name="Logout" value="Logout">
</form>
</cfoutput>
所以看一下ajax响应,logout表单被放置了infornt,所以select框没有解析这个值。我在Application.cfc中删除了这个部分,页面运行得很好。 非常感谢您的帮助! ^ _ ^