Link to home
Create AccountLog in
Avatar of erikTsomik
erikTsomikFlag for United States of America

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="FacultySearch2" extends="hb50.internal.search">
      <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="listResults" SearchFName="#form.first#" SearchLName="#form.last#">
            <cfinvoke method="getMemberDataListed" returnvariable="listResults2" SearchFName="#form.first#" SearchLName="#form.last#">
                        
            <!--- build search interface --->
            <cfsavecontent variable="output.body">
                  <cfoutput>
                  <cfdump var="#listResults2.RecordCount#">
                        <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#"</cfif> 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#?method=getSearchResults&LName=#urlencodedformat(LName)#&FName=#urlencodedformat(FName)#&Detail=Yes">#fname#,#lname# </a>  </td>  <br />
                                    <td valign="top">#DivMixed#</td>
                                    <td valign="top">#Unit#</td>
                        <br />
                              
                              </cfloop>
                        
                                                
                  </tr>                        
            </cfif><br />      </cfoutput>
            </table>
 <br />

           
       
           
                  
            <!---<cfdump var="#listResults.RecordCount#">--->
            <!---<cfdump var="#listResults2.RecordCount#">--->
                  
            </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.SearchFName"  default="">
            <cfparam name="arguments.SearchLName" default="">
            
            <cfquery name="ListFaculty" datasource="#application.datasource2#">
            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.SearchFName>
            <cfset MemberData.lname=Arguments.SearchLName>
            
            
            <!--- Select data about the faculty member  --->
            <cfquery name="getMember" datasource="#application.datasource2#">
                  Select * from tblDirectory where fname like '#arguments.SearchFName#%' or lname like '%#arguments.SearchLName#%'
            </cfquery>
                  <cfset MemberData.Pubtit=getMember.Pubtit>
                  <cfset MemberData.Title=getMember.Title>
                  <cfset MemberData.WorkPlace=getMember.WorkPlace>
                  <cfset MemberData.Extension=getMember.Extension>
                  <cfset MemberData.WPhone=getMember.WPhone>
                  <cfset MemberData.Email=getMember.WPhone>
                  <cfset MemberData.EMailAlias=getMember.EMailAlias>
                  <cfset MemberData.DivMixed=getMember.DivMixed>
                  <cfset MemberData.Unit=getMember.Unit>
                  
                  <cfset MemberData.MembersQuery=getMember>
                  
      
      <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.SearchFName,arguments.SearchLName)>
                        <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.WorkPlace#</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(listResults.EMail)#">#LCase(ViewMemberData.EMail)#</a></td>
      </tr>
      <tr>
          <td><b>EMail Alias:</b></td>
          <td><a href="mailto:#LCase(listResults.EMailAlias)#">#LCase(ViewMemberData.EMailAlias)#</a></td>
      </tr>
      <tr>
          <td><b>Division:</b></td>
          <td>#ViewMemberData.DivMixed#</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>
 
ASKER CERTIFIED SOLUTION
Avatar of mihaimm
mihaimm

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer