Highlighted

Composant cfc ou include

New Here ,
Sep 11, 2018

Copy link to clipboard

Copied

Bonjour,

Je cherche à faire un composant ou un include pour faire une table qui alimente une autre table ( Pays - ville).

Etant débutant, j'ai trouvé du code sur un site mais malheureusement ...

<cfcomponent>

<cfform name="mycfform">

  <CFQUERY datasource="#session.dbname#" name="AddTable">

SELECT

Pays,

Ville

FROM Monde

WHERE sitename='#session.site#'

  <cfselect name="#Pays#" bind="cfc:bindFcns.getpays()" bindonload="true">

  <option name="0">--#Pays#--</option>

  </cfselect>

  <cfselect name="#Ville#" bind="cfc:bindFcns.getvilles({#pays#})">

  <option name="0">--#ville#--</option>

  </cfselect>

  </CFQUERY>

</cfform>

</cfcomponent>

Merci par avance

Marc

Adobe Community Professional
Correct answer by BKBK | Adobe Community Professional

Oh, two more things, just in case you need them:

1) to display multiple items in the select list, use the size attribute.

2) remove the <br> tag to display the lists side by side.

For example, the following will display a maximum of 5 countries and 8 cities:

<cfselect name="pays" bind="cfc:Cfc.bindFcns.getPays()" bindonload="true" size="5"/>

<cfselect name="ville" bind="cfc:Cfc.bindFcns.getVilles({pays})" size="8"/>

Views

518

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Composant cfc ou include

New Here ,
Sep 11, 2018

Copy link to clipboard

Copied

Bonjour,

Je cherche à faire un composant ou un include pour faire une table qui alimente une autre table ( Pays - ville).

Etant débutant, j'ai trouvé du code sur un site mais malheureusement ...

<cfcomponent>

<cfform name="mycfform">

  <CFQUERY datasource="#session.dbname#" name="AddTable">

SELECT

Pays,

Ville

FROM Monde

WHERE sitename='#session.site#'

  <cfselect name="#Pays#" bind="cfc:bindFcns.getpays()" bindonload="true">

  <option name="0">--#Pays#--</option>

  </cfselect>

  <cfselect name="#Ville#" bind="cfc:bindFcns.getvilles({#pays#})">

  <option name="0">--#ville#--</option>

  </cfselect>

  </CFQUERY>

</cfform>

</cfcomponent>

Merci par avance

Marc

Adobe Community Professional
Correct answer by BKBK | Adobe Community Professional

Oh, two more things, just in case you need them:

1) to display multiple items in the select list, use the size attribute.

2) remove the <br> tag to display the lists side by side.

For example, the following will display a maximum of 5 countries and 8 cities:

<cfselect name="pays" bind="cfc:Cfc.bindFcns.getPays()" bindonload="true" size="5"/>

<cfselect name="ville" bind="cfc:Cfc.bindFcns.getVilles({pays})" size="8"/>

Views

519

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 11, 2018 0
New Here ,
Sep 13, 2018

Copy link to clipboard

Copied

Pas d'aide ???

Marc

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 13, 2018 0
New Here ,
Sep 16, 2018

Copy link to clipboard

Copied

I am trying to make a component or an include to make a table that feeds another table (Country - city).

Exemple.gif

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 16, 2018 0
Adobe Community Professional ,
Sep 16, 2018

Copy link to clipboard

Copied

bindFcns.cfc

<cfcomponent>

<cffunction name="getPays" access="remote" returntype="array">

    <cfset var paysQry = "">

     <cfset var paysArray = arrayNew(2)>

    <cfquery name = "paysQry" dataSource = "#session.dbname#">

    SELECT Pays

    FROM Monde

    WHERE sitename=<cfqueryparam cfsqltype="cf_sql_varchar" value="#session.site#">

    ORDER BY pays

    </cfquery>

    <!--- Values for the first (the default) select option --->

    <cfset anneeArray[1][1]="">

    <cfset anneeArray[1][2]="Sélectionnez un pays">

    <cfloop query="paysQry">

    <cfset anneeArray[currentrow+1][1]=paysQry.pays>

    <cfset anneeArray[currentrow+1][2]=paysQry.pays>

    </cfloop>

    <cfreturn paysArray>

</cffunction>

<cffunction name="getVilles" access="remote" returntype="array">

    <cfargument name="cePays" required="true" type="string">

    <cfset var villesQry = "">

    <cfset var villesArray = arrayNew(2)>

    <cfquery name = "villesQry" dataSource = "#session.dbname#">

    SELECT ville

    FROM Monde

    WHERE pays = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.cePays#">

    ORDER BY ville  

    </cfquery>

    <!--- Values for the first (the default) select option --->

    <cfset villesArray[1][1]="">

    <cfset villesArray[1][2]="Sélectionnez une ville">

    <cfloop query="villesQry">

    <cfset villesArray[currentrow+1][1]=villesQry.ville>

    <cfset villesArray[currentrow+1][2]=villesQry.ville>

    </cfloop>

    <cfreturn villesArray>

</cffunction>

</cfcomponent>

villes.cfm

<cfform name="villesEtPays">

  <cfselect name="pays" bind="cfc:bindFcns.getPays()" bindonload="true" />

<br>

  <cfselect name="ville" bind="cfc:bindFcns.getVilles({pays})" />

</cfform>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 16, 2018 0
New Here ,
Sep 17, 2018

Copy link to clipboard

Copied

Bonjour,

Avant tout merci pour cela.

Mais malheureusement j'ai encore un soucis car j'ai ce message :

bing failed for select box country. bing value is not a 2D array or valid serialized query.

J'ai mis mon Cfc dans une directory Cfc à la racine.

Merci par avance

Cordialement

Hello,

First of all thank you for that.

But unfortunately I still have a problem because I have this message:

failed box for select box country. bing value is not a 2D array or valid serialized query.

I put my Cfc in a Cfc directory at the root.

thanks in advance

cordially

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 17, 2018 0
Adobe Community Professional ,
Sep 17, 2018

Copy link to clipboard

Copied

Could you please show us your code. You are apparently using a variable called "bing".

For a start, you could just copy the code I have provided.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 17, 2018 0
New Here ,
Sep 18, 2018

Copy link to clipboard

Copied

Bonjour,

Je n'ai pratiquement pas changé votre code !

Hello,

I have hardly changed your code!

bindfcns.cfc (in Cfc)

<CFINCLUDE template="../admin/inc_init_admin.cfm">

<CFINCLUDE template="../admin/inc_verif_var2.cfm">

<cfcomponent>

<cffunction name="getPays" access="remote" returntype="array">

<cfset var paysQry = "">

<cfset var paysArray = arrayNew(2)>

<cfquery name = "paysQry" dataSource = "#session.dbname#">

SELECT Pays

FROM Monde

WHERE sitename=<cfqueryparam cfsqltype="cf_sql_varchar" value="#session.site#">

ORDER BY pays

</cfquery>

<!--- Values for the first (the default) select option --->

<cfset anneeArray[1][1]="">

<cfset anneeArray[1][2]="Sélectionnez un pays">

<cfloop query="paysQry">

<cfset anneeArray[currentrow+1][1]=paysQry.pays>

<cfset anneeArray[currentrow+1][2]=paysQry.pays>

</cfloop>

<cfreturn paysArray>

</cffunction>

<cffunction name="getVilles" access="remote" returntype="array">

<cfargument name="cePays" required="true" type="string">

<cfset var villesQry = "">

<cfset var villesArray = arrayNew(2)>

<cfquery name = "villesQry" dataSource = "#session.dbname#">

SELECT ville

FROM Monde

WHERE pays = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.cePays#">

ORDER BY ville 

</cfquery>

<!--- Values for the first (the default) select option --->

<cfset villesArray[1][1]="">

<cfset villesArray[1][2]="Sélectionnez une ville">

<cfloop query="villesQry">

<cfset villesArray[currentrow+1][1]=villesQry.ville>

<cfset villesArray[currentrow+1][2]=villesQry.ville>

</cfloop>

<cfreturn villesArray>

</cffunction>

</cfcomponent>

Villes.cfm (in Admin)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<CFINCLUDE template="inc_init_admin.cfm">

<CFINCLUDE template="inc_verif_var2.cfm">

<title>Essai pays/villes</title>

</head>

<body>

<cfform name="villesEtPays">

<cfselect name="pays" bind="../Cfc/bindFcns.getPays()" bindonload="true" />

<br>

<cfselect name="ville" bind="../Cfc/cfc:bindFcns.getVilles({pays})" />

</cfform>

</body>

</html>

Accès : Monde => Num Pays Ville

Merci pour votre aide

Thanks for your help

Marc

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 18, 2018 0
Adobe Community Professional ,
Sep 19, 2018

Copy link to clipboard

Copied

marcp12146864  wrote

<cfselect name="pays" bind="../Cfc/bindFcns.getPays()" bindonload="true" />

<br>

<cfselect name="ville" bind="../Cfc/cfc:bindFcns.getVilles({pays})" />

<cfselect name="pays" bind="cfc:Cfc.bindFcns.getPays()" bindonload="true" />

<br>

<cfselect name="ville" bind="cfc:Cfc.bindFcns.getVilles({pays})" />

(cfc: means the bind is to a CFC)

paths:

\admin\Cfc\bindfcns.cfc

\admin\villes.cfm

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 19, 2018 0
New Here ,
Sep 20, 2018

Copy link to clipboard

Copied

Ce programme est maudit ... et je ne vois plus rien :

This program is cursed ... and I can not see anything:

paths:

\admin\Cfc\bindfcns.cfc

\admin\villes.cfm

Invalid CFML construct found on line 4 at column 1. 

  ColdFusion was looking at the following text:

<

The CFML compiler was processing:

    < marks the beginning of a ColdFusion tag.Did you mean LT or LTE?
  
  The error occurred in \\192.168.0.1\H3637\zennetbuilder.com\Admin\Cfc\bindFcns.cfc: line 4
2 : <CFINCLUDE template="../admin/inc_verif_var2.cfm"> 3 : 4 : <cfcomponent> 

Villes.cfm

<cfform name="villesEtPays">

<cfselect name="pays" bind="cfc:Cfc.bindFcns.getPays()" bindonload="true" />

<br>

<cfselect name="ville" bind="cfc:Cfc.bindFcns.getVilles({pays})" />

</cfform>

Merci encore

thanks again

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 20, 2018 0
Adobe Community Professional ,
Sep 20, 2018

Copy link to clipboard

Copied

It looks like you have some CFML code preceding the opening CFCOMPONENT tag. I don't think this is allowed.

Dave Watts, Fig Leaf Software

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 20, 2018 0
New Here ,
Sep 20, 2018

Copy link to clipboard

Copied

Mais si je supprime ces includes, je n'ai plus mes informations de session !

But if I delete these includes, I do not have my session information anymore!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 20, 2018 0
Adobe Community Professional ,
Sep 20, 2018

Copy link to clipboard

Copied

Well, you could include a CFINCLUDE within the actual CFCOMPONENT block I think, or within one of the CFFUNCTIONs defined within that component. But in general, I'd say you're doing something wrong if you expect components and functions to be aware of the application state. That's what arguments are for. Functions especially should usually be stateless.

Dave Watts, Fig Leaf Software

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 20, 2018 0
Adobe Community Professional ,
Sep 20, 2018

Copy link to clipboard

Copied

marcp12146864  wrote

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<CFINCLUDE template="inc_init_admin.cfm">

<CFINCLUDE template="inc_verif_var2.cfm">

<title>Essai pays/villes</title>

</head>

Are those headers? If not, then you should put them after between the tags <body> and  </body>

Mais si je supprime ces includes, je n'ai plus mes informations de session !

But if I delete these includes, I do not have my session information anymore!

You should delete the includes from bindfcns.cfc. After all, they are already in the page villes.cfm. That is sufficient to guarantee your session!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 20, 2018 0
Adobe Community Professional ,
Sep 20, 2018

Copy link to clipboard

Copied

I'm pretty sure that all META elements should be placed within the HEAD element, whether they are analogs for headers or not.

Dave Watts, Fig Leaf Software

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 20, 2018 0
New Here ,
Sep 21, 2018

Copy link to clipboard

Copied

Je pensais qu'étant donné qu'ils étaient dans ville, on n'avait pas besoin de les mettre dans le cfc mais cela ne fonctionne pas !

I thought that since they were in town, we did not need to put them in the cfc but it does not work!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 21, 2018 0
New Here ,
Sep 21, 2018

Copy link to clipboard

Copied

J'ai essayé de les mettre entre head ou entre body mais j'ai toujours le même message !

I tried to put them between head or body but I always have the same message!

Invalid CFML construct found on line 6 at column 1. 

  ColdFusion was looking at the following text:

<

The CFML compiler was processing:

    < marks the beginning of a ColdFusion tag.Did you mean LT or LTE?
  
  The error occurred in \\192.168.0.1\H3637\zennetbuilder.com\Admin\Cfc\bindFcns.cfc: line 6
4 : </body> 

Mercissss pour votre aide

Mercissss for your help

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 21, 2018 0
Adobe Community Professional ,
Sep 21, 2018

Copy link to clipboard

Copied

I think you misunderstood. Delete the following 2 lines from the file bindFcns.cfc

<CFINCLUDE template="../admin/inc_init_admin.cfm">

<CFINCLUDE template="../admin/inc_verif_var2.cfm">

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 21, 2018 0
New Here ,
Sep 22, 2018

Copy link to clipboard

Copied

Non j'ai bien compris: j'ai enlevé les 2 lignes dans bindFcns.cfc!

Mais j'ai cette erreur !!

No I understood correctly: I removed the 2 lines in bindFcns.cfc!

But I have this error !!

Erreur.gif

Merci

Tank you

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 22, 2018 0
Adobe Community Professional ,
Sep 22, 2018

Copy link to clipboard

Copied

The error occurs because the session variables are undefined. You may or may not be familiar with the application file, Application.cfc. So I shall suggest a solution that does not assume knowledge of it.

Define 2 variables at the beginning of the file bindFcns.cfc, as follows:

<cfcomponent>

<cfset session.dbname="BKBK_DB_name">

<cfset session.site="app.bkbk.com">

<cffunction name="getPays" access="remote" returntype="array">

etc.

Replace the values BKBK_DB_name and app.bkbk.com with your own.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 22, 2018 0
New Here ,
Sep 24, 2018

Copy link to clipboard

Copied

Ce n'est pas le cas. En effet, lorsque j'affiche les variables, j'ai les bonnes informations

Erreur2.gifJe suis dégoûté! 😞

This is not the case. Indeed, when I display the variables, I have the right information

I'm disgusted! 😞

Tank you

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 24, 2018 0
Adobe Community Professional ,
Sep 24, 2018

Copy link to clipboard

Copied

Don't worry. We shall get there.

Are you using Application.cfc?

If yes, then you should include the following code in onSessionStart:

<cfset session.dbname="H3637zennet">

<cfset session.site="SoLivres">

If no, then you should create a file called Application.cfc in the directory /Admin/Cfc/. The content of the file is:

<cfcomponent displayname="ApplicationFile" hint="This file runs before every request and initializes your application">

    <cfset this.name = "MesLivres">

    <cfset this.applicationTimeout = "#createTimespan(1,0,0,0)#">

    <cfset this.sessionManagement = "true">

    <cfset this.sessionTimeout = "#createTimeSpan(0,0,20,0)#">

<cffunction name="onApplicationStart" returntype="boolean">

    <cfreturn true>

</cffunction>

<cffunction name="onSessionStart">

    <cfset session.dbname="H3637zennet">

    <cfset session.site="SoLivres">

</cffunction>

</cfcomponent>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 24, 2018 0
Adobe Community Professional ,
Sep 25, 2018

Copy link to clipboard

Copied

Has your original question been answered? If so, mark the correct answer. It will help someone else in future.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 25, 2018 0
New Here ,
Sep 27, 2018

Copy link to clipboard

Copied

Désespoir ! toujours pas de résultats malgré vos encouragements !

Je ne sais plus où chercher !

Erreur3.gif

Despair! still no results despite your encouragement!

I do not know where to look!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 27, 2018 0
Adobe Community Professional ,
Sep 27, 2018

Copy link to clipboard

Copied

May I help? I have sent you a private message containing my e-mail address. Zip your files (so as to preserve the directory structure) and mail them to me.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 27, 2018 0
Adobe Community Professional ,
Sep 30, 2018

Copy link to clipboard

Copied

Could you please give the forum your feedback. Did you apply Application.cfc as suggested?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 30, 2018 0
Adobe Community Professional ,
Oct 02, 2018

Copy link to clipboard

Copied

I have looked at the files you sent me. We have to make some corrections:

1) In the above code for bindFcns.cfc, the 2-D array should be called paysArray not anneeArray (my bad).

2) Your database has no column called sitename, so your pays query should be

    SELECT Pays

    FROM Monde

    ORDER BY pays

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 02, 2018 0
Adobe Community Professional ,
Oct 03, 2018

Copy link to clipboard

Copied

If you wish to get distinct countries, then modify the query to

SELECT DISTINCT pays

FROM Monde

ORDER BY pays

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 03, 2018 1
Adobe Community Professional ,
Oct 06, 2018

Copy link to clipboard

Copied

Oh, two more things, just in case you need them:

1) to display multiple items in the select list, use the size attribute.

2) remove the <br> tag to display the lists side by side.

For example, the following will display a maximum of 5 countries and 8 cities:

<cfselect name="pays" bind="cfc:Cfc.bindFcns.getPays()" bindonload="true" size="5"/>

<cfselect name="ville" bind="cfc:Cfc.bindFcns.getVilles({pays})" size="8"/>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 06, 2018 0