Pergunta

I am trying to create a form with 3 select boxes that are bound to a cfc (triple related cfselect). If I remove the Application.cfc, the code runs just fine, the select box gives me the data I need. However, when I add Application.cfc which has cflogin function which requires users to login before they are able to use any page than my triple related select boxes do not work anymore. The select box just doesn't give out any data from the query in the function. It still connects to the function page, because when I change the name on the bind of the cfselect, it will let me know that that function does not exist in the component. I am not sure what I have to do to make the triple related cfselect work with cflogin in place.
I am using ColdFusion 10
I really appreciate any suggestions.
Thanks, Niva

I added the code: This is code on form

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

Code on component: 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>

Here is my 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>
Foi útil?

Solução

I found the problem. Because in my Application.cfc has this part:

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

   </cfoutput> 

So looking at the ajax response the logout form is placed infornt so the select box didnt parse the value.I removed this partin the Application.cfc and the page run just fine. Thank you so much for all your help! ^_^

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top