Groups | Blog | Home
all groups > coldfusion flash integration > february 2006 >

coldfusion flash integration : Specifically Referencing and Populating a CFSELECT Data field


Sven
2/13/2006 5:48:11 PM
QUESTION ..... How do I get the CFSELECT (CRITS) to populate the data component
as well as the labelField component. There must be a path crits.item.data or
something I need to deal with. I am totally hopeless, but hopeful that someone
can figure out what I am trying to do.

Essentially there are 2 areas of concern for me in a CFSELECT 1) the display
field (easy), 2) the associated data field (can't figure out) neither how to
reference, or change.

I am using 3 CFSELECTS, that are chained in that REPS changes CRITS changes
RECLOCS

The Webservice (getdata2) returns a query with 2 fields DATA and LABEL

I set the DISPLAY or LABELFIELD by saying
------
myselect.dataProvider = result //the result from the webservice
myselect.labelField = "LABEL"
------
How do I set the data field
How do access the data in the returned resultset
------
I am using standard RESPONSEHANDLER.ONRESULT code found on this site.
CODE follows.......
================================= WEBSERVICE (cfc)
<cfcomponent>

<cffunction name="getReports" access="remote" output="false"
returntype="query">
<cfquery name="qry" datasource="pps1">
select id as thid,report as reps
from IATTESTING_QUERY
group by id,report
</cfquery>
<cfreturn qry>
</cffunction>
<cffunction name="getCriteria" access="remote" output="false"
returntype="query">
<cfargument name="mysubID" type="string" required="yes">
<cfquery name="qry5" datasource="pps1">
select subid as data,
subdesc as label
from iattesting_query
where id = '#mysubID#'
group
by subid,subdesc
</cfquery>
<cfreturn qry5>
</cffunction>
<cffunction name="getReclocs" access="remote" output="false"
returntype="query">
<cfargument name="lup" type="string" required="yes">
<cfquery name="qry1x" datasource="pps1">
select lup,
thequery
from iattesting_query
where lup = '#lup#'
group
by lup,thequery
</cfquery>
<cfquery name="qry2x" datasource="pps1">
#qry1x.thequery#
</cfquery>
<cfreturn qry2x>
</cffunction>
</cfcomponent>

================================= APPLICATION (cfm)
<cfset theHost=cgi.HTTP_HOST>
<!--- <cfset theHost="wjwkstn1925"> --->
<cfsilent>
<cfsavecontent variable="buttonStyle">
corner-radius: 2;
borderThickness: 0;
</cfsavecontent>
<cfsavecontent variable="panelStyle">
panelBorderStyle:'roundCorners';
themeColor:#FE7E00;
headerColors:#F2CB2A, #FFE57A;
backgroundColor:#FFE57A;
align:Center;
</cfsavecontent>

</cfsilent>

<cfquery name="reps" datasource="pps1">
select id as thid,report as reps
from IATTESTING_QUERY
group by id,report
</cfquery>
<cfquery name="critsp" datasource="pps1">
select subid as data,
subdesc as label
from iattesting_query
where id = 'B'
group
by subid,subdesc
</cfquery>
<cfquery name="qry" datasource="pps1">
select lup,
thequery
from iattesting_query
where lup = 'B1'
group
by lup,thequery
</cfquery>
<cfquery name="reclocs" datasource="pps1">
#qry.thequery#
</cfquery>

<cfform name="myform" format="flash" >
<cfformitem type="script">


var typex: Object;

function getData()
{
<cfoutput>
var connection:mx.remoting.Connection =
mx.remoting.NetServices.createGatewayConnection("http://#theHost#/flashservices/
gateway/");
</cfoutput>

var myService:mx.remoting.NetServiceProxy;
var responseHandler = {};
var posts = posts;
responseHandler.onResult = function( results: Object ):Void {
posts.dataProvider = results;
mx.managers.CursorManager.removeBusyCursor();
}

responseHandler.onStatus = function( stat: Object ):Void {
alert("Error while calling web service:" + stat.description);
mx.managers.CursorManager.removeBusyCursor();
}
<cfoutput>
myService =
connection.getService("http://#theHost#/successcriteria/webservices/IATWS.cfc?ws
dl", responseHandler );
</cfoutput>
mx.managers.CursorManager.setBusyCursor();
myService.getReclocs(posts2.selectedItem.data + crits.selectedItem.data);
}
function getData2()
{
<cfoutput>
var connection2:mx.remoting.Connection =
mx.remoting.NetServices.createGatewayConnection("http://#theHost#/flashservices/
gateway/");
</cfoutput>

var myService2:mx.remoting.NetServiceProxy;
var responseHandler2 = {};
var crits = crits;

responseHandler2.onResult = function( results2: Object ):Void {

crits.dataProvider = results2;
crits.labelField = "LABEL";
_root.typex=results2;

mx.managers.CursorManager.removeBusyCursor();
}

responseHandler2.onStatus = function( stat: Object ):Void {
alert("Error while calling web service:" + stat.description);
mx.managers.CursorManager.removeBusyCursor();
}
<cfoutput>
myService2 =
connection2.getService("http://#theHost#/successcriteria/webservices/IATWS.cfc?w
sdl", responseHandler2 );
</cfoutput>
mx.managers.CursorManager.setBusyCursor();
myService2.getCriteria(posts2.selectedItem.data);

}
function getData3()
{
var myGrid = myGrid;
myGrid.dataProvider = _root.typex;
_root.myText.text="";
alert(crits.selectedItem.data);
for(var i in _root.typex)
{
_root.myText.text = _root.myText.text + "x: " + i.toString() + "\n";
}

}
</cfformitem>
<cfformgroup type="panel" style="#panelStyle#">
<cfformgroup type="hbox">
<cfformgroup type="panel">
<cfselect name="posts" query="reclocs" display="RECLOC" VALUE="RECLOC"
size="15"/>
</cfformgroup>
<cfformgroup type="panel">
<cfselect name="posts2" selected="B" query="reps" display="reps" size="7"
value="thid" onChange="getData2();" />
<cfselect multiple="no" name="crits" query="critsp" display="label"
value="data" selected="1" size="5" onchange="getData3();" />
</cfformgroup>
<cfformgroup type="panel">
<cfgrid name="myGrid">
<cfgridcolumn name="LABEL">
<cfgridcolumn name="DATA">
<cfgridcolumn name="SUBID">
<cfgridcolumn name="SUBDESC">
</cfgrid>
<cftextarea name="myText" message="test" enabled="yes" wrap="physical"
rows="10" visable="yes"></cftextarea>
</cfformgroup>
</cfformgroup>
</cfformgroup>

</cfform>

The ScareCrow
2/13/2006 11:56:32 PM
The following link will answer all your questions

http://www.asfusion.com/blog/index.cfm

AddThis Social Bookmark Button