erikTsomik
asked on
Coldfusion member list usinf cfc in coldfusion
I need help while creating search list. I have to design search interface using cfc which supposed to list all the mebers specified in the text boxes and then After I get list of members I should be able to retrieve their bios. So the first step is working fine I am able to see all specified members now the question is how can I see their bio? I wrote a cfc function which supposed to do that but i does not. GetFrontEnd function is the main function which calls the method.
<LINK rel="stylesheet" type="text/css" href="../work_style.css">
<cfcomponent displayname="FacultySearch 2" extends="hb50.internal.sea rch">
<cffunction name="getFrontEnd" access="public" returntype="struct">
<cfparam name="FORM.first" default="">
<cfparam name="FORM.last" default="">
<cfparam name="URL.Detail" default="No">
<cfsetting showdebugoutput="no">
<cfinvoke method="getSearchResults" returnvariable="listResult s" SearchFName="#form.first#" SearchLName="#form.last#">
<cfinvoke method="getMemberDataListe d" returnvariable="listResult s2" SearchFName="#form.first#" SearchLName="#form.last#">
<!--- build search interface --->
<cfsavecontent variable="output.body">
<cfoutput>
<cfdump var="#listResults2.RecordC ount#">
<form action="#CGI.SCRIPT_NAME#" method="post">
First Name:<input type="text" name="first" <cfif isDefined('first')>value=" #first#"</ cfif> style="width:50%"><br />
Last Name:<input type="text" name="last" <cfif isDefined('last')>value="# last#"</cf if> style="width:50%">
<input type="submit" name="submit" value="Search" style="width:65;" />
</form>
<cfif #listResults.recordcount# eq 0>
<strong>The faculty or staff member you entered does not exist in the directory. <br><br>
<cfelseif #listResults.recordcount# gte 1>
<table width="600" cellpadding="5">
<tr>
<td colspan="3"><strong>The name you entered matches #listResults.recordcount# of our faculty or staff members. Please click on the person's name to view that person's directory information.</strong><br>< br></td>
</tr>
<tr class="grayrow">
<th align="left" class="graytext">Name</th>
<th align="left" class="graytext">Division< /th>
<th align="left" class="graytext">Unit</th>
</tr> <br />
<tr><cfloop query="listResults">
<td valign="top">
<a href="#cgi.SCRIPT_NAME#?me thod=getSe archResult s&LName=#u rlencodedf ormat(LNam e)#&FName= #urlencode dformat(FN ame)#&Deta il=Yes">#f name#,#lna me# </a> </td> <br />
<td valign="top">#DivMixed#</t d>
<td valign="top">#Unit#</td>
<br />
</cfloop>
</tr>
</cfif><br /> </cfoutput>
</table>
<br />
<!---<cfdump var="#listResults.RecordCo unt#">--->
<!---<cfdump var="#listResults2.RecordC ount#">--- >
</cfsavecontent>
<cfreturn output />
</cffunction>
<cffunction name="getSearchResults" access="public" returntype="query" output="true">
<cfargument name="SearchFName" type="string" required="no">
<cfargument name="SearchLName" type="string" required="no">
<cfparam name="URL.Lname" default="">
<cfparam name="URL.Fname" default="">
<cfparam name="arguments.SearchFNam e" default="">
<cfparam name="arguments.SearchLNam e" default="">
<cfquery name="ListFaculty" datasource="#application.d atasource2 #">
SELECT * from tblDirectory
<cfif Form.Last neq "" and Form.First neq "">
WHERE LName like '%#arguments.SearchLName#% ' and FName like '#arguments.SearchFName#%'
<cfelseif Form.Last neq "" and Form.First eq "">
Where LName like '%#arguments.SearchLName#% '
<cfelseif Form.Last eq "" and Form.First neq "">
Where FName like '#arguments.SearchFName#%'
<cfelse>
Where LName like '%#URL.LName#%' and FName like '#URL.FName#%'
</cfif>
ORDER BY LName, FName, SSN
</cfquery>
<cfreturn ListFaculty />
</cffunction>
<cffunction name="getMemberData" returntype="struct">
<cfargument name="SearchFName" type="string" required="no">
<cfargument name="SearchLName" type="string" required="no">
<cfset var MemberData=StructNew()>
<cfset MemberData.fname=Arguments .SearchFNa me>
<cfset MemberData.lname=Arguments .SearchLNa me>
<!--- Select data about the faculty member --->
<cfquery name="getMember" datasource="#application.d atasource2 #">
Select * from tblDirectory where fname like '#arguments.SearchFName#%' or lname like '%#arguments.SearchLName#% '
</cfquery>
<cfset MemberData.Pubtit=getMembe r.Pubtit>
<cfset MemberData.Title=getMember .Title>
<cfset MemberData.WorkPlace=getMe mber.WorkP lace>
<cfset MemberData.Extension=getMe mber.Exten sion>
<cfset MemberData.WPhone=getMembe r.WPhone>
<cfset MemberData.Email=getMember .WPhone>
<cfset MemberData.EMailAlias=getM ember.EMai lAlias>
<cfset MemberData.DivMixed=getMem ber.DivMix ed>
<cfset MemberData.Unit=getMember. Unit>
<cfset MemberData.MembersQuery=ge tMember>
<cfreturn memberData />
</cffunction>
<cffunction name="getMemberDataListed" access="remote" returntype="struct">
<cfargument name="SearchFName" type="string" required="no">
<cfargument name="SearchLName" type="string" required="no">
<cfset var ViewMemberData= getMemberData(Arguments.Se archFName, arguments. SearchLNam e)>
<cfsavecontent variable="output.body">
<table border="0" cellspacing="2" cellpadding="2" align="left">
<!--- Do as cfoutput without the query name to get the first row only
Some people are listed in the db twice because they are in 2 units. --->
<cfoutput>
<!--- Display published title. If none exists, display the payroll title --->
<cfif #ViewMemberData.Pubtit# IS ''>
<cfset JobTitle = #ViewMemberData.Title#>
<cfelse>
<cfset JobTitle = #ViewMemberData.Pubtit#>
</cfif>
<tr>
<td><b>Name:</b></td>
<td>#ViewMemberData.FName# #ViewMemberData.LName#</td >
</tr>
<tr>
<td><b>Address:</b></td>
<td>#ViewMemberData.WorkPl ace#</td>
</tr>
<tr>
<td><b>Published Number:</b></td>
<cfif #ViewMemberData.Extension# IS ''>
<td>#ViewMemberData.WPhone #</td>
<cfelse>
<td>#ViewMemberData.WPhone # ext #ViewMemberData.Extension# </td>
</cfif>
</tr>
<tr>
<td><b>EMail:</b></td>
<td><a href="mailto:#LCase(listRe sults.EMai l)#">#LCas e(ViewMemb erData.EMa il)#</a></ td>
</tr>
<tr>
<td><b>EMail Alias:</b></td>
<td><a href="mailto:#LCase(listRe sults.EMai lAlias)#"> #LCase(Vie wMemberDat a.EMailAli as)#</a></ td>
</tr>
<tr>
<td><b>Division:</b></td>
<td>#ViewMemberData.DivMix ed#</td>
</tr>
<tr>
<td><b>Unit:</b></td>
<td>#ViewMemberData.Unit#< /td>
</tr>
<tr>
<td><b>Title:</b></td>
<td>#JobTitle#</td>
</tr>
</cfoutput>
</table>
</table>
</td>
</tr>
</cfsavecontent>
<cfreturn output/>
</cffunction>
</cfcomponent>
<LINK rel="stylesheet" type="text/css" href="../work_style.css">
<cfcomponent displayname="FacultySearch
<cffunction name="getFrontEnd" access="public" returntype="struct">
<cfparam name="FORM.first" default="">
<cfparam name="FORM.last" default="">
<cfparam name="URL.Detail" default="No">
<cfsetting showdebugoutput="no">
<cfinvoke method="getSearchResults" returnvariable="listResult
<cfinvoke method="getMemberDataListe
<!--- build search interface --->
<cfsavecontent variable="output.body">
<cfoutput>
<cfdump var="#listResults2.RecordC
<form action="#CGI.SCRIPT_NAME#"
First Name:<input type="text" name="first" <cfif isDefined('first')>value="
Last Name:<input type="text" name="last" <cfif isDefined('last')>value="#
<input type="submit" name="submit" value="Search" style="width:65;" />
</form>
<cfif #listResults.recordcount# eq 0>
<strong>The faculty or staff member you entered does not exist in the directory. <br><br>
<cfelseif #listResults.recordcount# gte 1>
<table width="600" cellpadding="5">
<tr>
<td colspan="3"><strong>The name you entered matches #listResults.recordcount# of our faculty or staff members. Please click on the person's name to view that person's directory information.</strong><br><
</tr>
<tr class="grayrow">
<th align="left" class="graytext">Name</th>
<th align="left" class="graytext">Division<
<th align="left" class="graytext">Unit</th>
</tr> <br />
<tr><cfloop query="listResults">
<td valign="top">
<a href="#cgi.SCRIPT_NAME#?me
<td valign="top">#DivMixed#</t
<td valign="top">#Unit#</td>
<br />
</cfloop>
</tr>
</cfif><br /> </cfoutput>
</table>
<br />
<!---<cfdump var="#listResults.RecordCo
<!---<cfdump var="#listResults2.RecordC
</cfsavecontent>
<cfreturn output />
</cffunction>
<cffunction name="getSearchResults" access="public" returntype="query" output="true">
<cfargument name="SearchFName" type="string" required="no">
<cfargument name="SearchLName" type="string" required="no">
<cfparam name="URL.Lname" default="">
<cfparam name="URL.Fname" default="">
<cfparam name="arguments.SearchFNam
<cfparam name="arguments.SearchLNam
<cfquery name="ListFaculty" datasource="#application.d
SELECT * from tblDirectory
<cfif Form.Last neq "" and Form.First neq "">
WHERE LName like '%#arguments.SearchLName#%
<cfelseif Form.Last neq "" and Form.First eq "">
Where LName like '%#arguments.SearchLName#%
<cfelseif Form.Last eq "" and Form.First neq "">
Where FName like '#arguments.SearchFName#%'
<cfelse>
Where LName like '%#URL.LName#%' and FName like '#URL.FName#%'
</cfif>
ORDER BY LName, FName, SSN
</cfquery>
<cfreturn ListFaculty />
</cffunction>
<cffunction name="getMemberData" returntype="struct">
<cfargument name="SearchFName" type="string" required="no">
<cfargument name="SearchLName" type="string" required="no">
<cfset var MemberData=StructNew()>
<cfset MemberData.fname=Arguments
<cfset MemberData.lname=Arguments
<!--- Select data about the faculty member --->
<cfquery name="getMember" datasource="#application.d
Select * from tblDirectory where fname like '#arguments.SearchFName#%'
</cfquery>
<cfset MemberData.Pubtit=getMembe
<cfset MemberData.Title=getMember
<cfset MemberData.WorkPlace=getMe
<cfset MemberData.Extension=getMe
<cfset MemberData.WPhone=getMembe
<cfset MemberData.Email=getMember
<cfset MemberData.EMailAlias=getM
<cfset MemberData.DivMixed=getMem
<cfset MemberData.Unit=getMember.
<cfset MemberData.MembersQuery=ge
<cfreturn memberData />
</cffunction>
<cffunction name="getMemberDataListed"
<cfargument name="SearchFName" type="string" required="no">
<cfargument name="SearchLName" type="string" required="no">
<cfset var ViewMemberData= getMemberData(Arguments.Se
<cfsavecontent variable="output.body">
<table border="0" cellspacing="2" cellpadding="2" align="left">
<!--- Do as cfoutput without the query name to get the first row only
Some people are listed in the db twice because they are in 2 units. --->
<cfoutput>
<!--- Display published title. If none exists, display the payroll title --->
<cfif #ViewMemberData.Pubtit# IS ''>
<cfset JobTitle = #ViewMemberData.Title#>
<cfelse>
<cfset JobTitle = #ViewMemberData.Pubtit#>
</cfif>
<tr>
<td><b>Name:</b></td>
<td>#ViewMemberData.FName#
</tr>
<tr>
<td><b>Address:</b></td>
<td>#ViewMemberData.WorkPl
</tr>
<tr>
<td><b>Published Number:</b></td>
<cfif #ViewMemberData.Extension#
<td>#ViewMemberData.WPhone
<cfelse>
<td>#ViewMemberData.WPhone
</cfif>
</tr>
<tr>
<td><b>EMail:</b></td>
<td><a href="mailto:#LCase(listRe
</tr>
<tr>
<td><b>EMail Alias:</b></td>
<td><a href="mailto:#LCase(listRe
</tr>
<tr>
<td><b>Division:</b></td>
<td>#ViewMemberData.DivMix
</tr>
<tr>
<td><b>Unit:</b></td>
<td>#ViewMemberData.Unit#<
</tr>
<tr>
<td><b>Title:</b></td>
<td>#JobTitle#</td>
</tr>
</cfoutput>
</table>
</table>
</td>
</tr>
</cfsavecontent>
<cfreturn output/>
</cffunction>
</cfcomponent>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.