Project: Duplicate MLS

Move the MLS# results code from the search landing page to the index page.

Start Date: November 2, 2010
Deadline: Published Mid-December
Assigned by: Cass Herrin

http://172.20.0.74/index.cfm?fuseaction=listing.SearchLanding&searchConstraintType=mls&ln=10-569

1.

In the W folder, there is fbx_Circuits.cfm which has

  • techspedition_.Circuits.PhysicalPath.Listing = "Controllers/Listing/";
  • techspedition_.Circuits.VirtualPath.Listing = "w,Listing";

2.

So, the Controllers folder, Listing folder, the fbx_switch.cfm has
<cfcase value="SearchLanding">
<cfparam name="attributes.display" default="map">
   <cfif attributes.display eq "list">
      <cfset attributes.hiddenSftype = "Listing.PropertyListView">
      <cfset AddToQ('Listing.actSearchProperty')>

   <cfelse>

      <cfif isDefinedValue('attributes.ListingID')>
         <!--- listing provided, lookup address --->
         <cfset AddToQ('mListing.GetListingDetail')>
         <cfset AddToQ('mGeography.MapListingRegionResolver')>
      <cfelseif isDefinedValue('attributes.hsn') and isDefinedValue('attributes.address') and isDefinedValue('attributes.cit') and isDefinedValue('attributes.st') and isDefinedValue('attributes.zip')>
         <!--- address provided, lookup listing --->
         <cfset AddToQ('mListing.GetProperty')>
         <cfset AddToQ('mGeography.MapListingRegionResolver')>
      </cfif>

      <cfif IsDefined('url.boundaryState') AND url.boundaryState EQ "OFF">
      <cfelse>
      </cfif>

      <cfset AddToQ('Listing.SearchPropertyMapV3')>

   </cfif>
</cfcase>

3.

Model folder, mListing, switch GetListingDetail has
<cfset AddToQ('q.selPub_View')>

4.

W/Query/sel/selPub_View.cfm – added a dump and nothing happened.
Used svn log to find out:
r12655 | jgiven | 2009-10-14 15:53:04 -0700 (Wed, 14 Oct 2009) | 1 line
bugzID: 110663 - Days on windermere and cdom are now in the detail
------------------------------------------------------------------------
r12632 | jgiven | 2009-09-23 13:20:54 -0700 (Wed, 23 Sep 2009) | 1 line
bugzID: 109188 - Added AVM field to pub_data which gives Windermere agents the ability to turn zillow on and off on their listings.

5.

Looked at CF debugger window an saw Query in
/cf-instance/root/W/Views/vGeography/dspPP3MapLayout.cfm

<cfquery name="listing" datasource="windermereDSN">
      select * from pub_data with (nolock) where ln='#mlsArray[1]#'
</cfquery>

6.

So, Use an AJAX (Asynchronous JavaScript and XML) call to get this Select from the main page
JSON (JavaScript Object Notation) is a data exchange parser that can be used during an AJAX call.
http://www.fusionauthority.com/techniques/4593-using-ajax-with-coldfusion-part-i.htm

7.

Add a jQuery slideDown (like in /Views/vGeography/dspInteractiveMapControlLoactionSearch.cfm) inside the LocationGatewayTargetMls function in /js/map/locationGateway.js (line 666)

var mlslist=mls.split(",");

var msg = '<table width="100%" height="100%"><tr><td valign="top" class="locationTitle"><span class="pageTitle">Your search produced more than one option:</span></td></tr><tr><td valign="top">';

for (i=0; i < mlslist.length; i++ ){
   msg += '<div class="locationResults"><a href="http://www.windermere.com/index.cfm?fuseaction=
   listing.SearchLanding&ListingID=67285703" >' + mlslist[i] + '</a>' + '</div>';
}
msg += '<div class="locationResults"><a href="javascript:closeResultDialogue();" style="color: #660000">I\'ll try again. </a></div>';
msg += '</td></tr><tr><td valign="bottom" align="right"><a href="javascript:closeResultDialogue();">Close </a></td></tr></table>';

var resultsBox = document.getElementById( 'mapControlLocationSearchDisambiguator' );
   $("#mapControlLocationSearchDisambiguator").css("display","none");
   resultsBox.style.zIndex = 5000;
   resultsBox.style.padding = "20px";
   resultsBox.style.width = "920px";
   resultsBox.style.height = "220px";
   resultsBox.style.top = "143px";
   resultsBox.style.backgroundColor = "#f5f5f5";

   if (isDefined(document.getElementById("front_logo"))) {
      resultsBox.style.left = (findPosX(document.getElementById("front_logo")) - 10) + "px";
   } else {
      resultsBox.style.left = (findPosX(document.getElementById("main_content"))) + "px";
   }

   $("#mapControlLocationSearchDisambiguator").slideDown("slow");
   resultsBox.innerHTML = msg;

   Comment out the window switch
   if ( href ) {
   //location.href = href;
   }

8.

Create CFC to do query of Listing number - /W/CFC/MLSListing.cfc

<cfcomponent displayname="MLSListingData">
    <cffunction name="getMLSListing">
        <cfargument name="ListingID" required="yes">
        <cfquery name="q_getMLSListing" datasource="WindermereDSN">
            SELECT pub_data.address, pub_data.cit, pub_data.st, pub_data.id
            FROM pub_data
            WHERE pub_data.ln = '#ARGUMENTS.ListingID#'
        </cfquery>
        <cfreturn q_getMLSListing>
    </cffunction>
</cfcomponent>

9.

Create AJAX call to get listing (AJAX sample in /js/refresh/listing_detail.js)

var parsedMLS = { mls:mls }

      $.ajax({
            type: "POST",
            url : "/Models/mListing/actRequest_processor.cfm",
            data: ({
                  parsedMLS
            }),
            dataType: "json",
            success: function(response)
            {
                  if(response.recordcount > 1) {
                        dropdownMultiple(response);
                  } else if(response.recordcount == 1) {
                        location.href = href;
                  } else {
                        dropdownNone();
            }
      });

10.

11/14/10

Moved What's for Dinner JSON/AJAX tutorial into the Windermere/slloyd/ajax-json sub-directory.

  • index.html contains an ajax call which calls request_processor.cfm.
  • That file references two componenets: MLSListingData.cfc and cfjson.cfc
  • MLSListing.cfc queries pub_data to get an address and a city.
  • cfjson.cfc takes the query results and makes them json formatted.

Changed variables and database pointers to use pub_data and get address and city based on "ln". 10-569 shows 4 properties if you start at the request_processor.cfm file. If you start at the index, the text still does not change. Possibly, the success function is not firing.

Added error and complete callback functions, and they both fire. How do I debug an AJAX error? Adding an alert for response in the error function gives "undefiined."

11.

11/15/10

  1. Used response.status to discover that 200 means success. So, the ajax was successful, but will not go into "success."
  2. George says, the call was successful, but it is expecting a json object to come back, and it is not.
  3. Looking at request_processor.cfm, we see what looks like a well-formed json object, but JP notices the page also has the debugging info on it. Added <cfsetting showDebugOutput="No"> to cfm page and wah-la!

The json object has three top-level nodes: recordcount, columnlist and data. So, we can use response.recordcount to see if there is more than 1. To get the address of the second item: response.data.address[1] (zero-based)

Currently successful set of code is using the jquery file from the tutorial site. /js/jquery-1.3.1.min.js also works. So does http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js

NEXT TASK: Port over to location gateway and other files.

  • slloyd/ajax-json/index.html -> js/map/locationGateway.js
  • slloyd/ajax-json/request_processor.cfm -> Models/mListing/actRequest_processor.cfm
  • slloyd/ajax-json/MLSListingData.cfc -> CFC/MLSListingData.cfc
  • slloyd/ajax-json/cfjson.cfc -> CFC/cfjson.cfc

Instead of alert('hi'); use console.log('hi') to send data to the firebug console window. Make sure the console window is active when using, otherwize other js may break. Comment out all console.log entries before sending to QA.

12.

11/16/10

  • Added address, city (cit), state and id to SQL function MLSListingData.cfc
  • Updated table display in locationGateway.js with
    <a href="http://www.windermere.com/index.cfm?fuseaction=listing.SearchLanding&ListingID=' + multiples.data.ID[i] + '" >' + multiples.data.ADDRESS[i] + ',&nbsp;&nbsp; ' + multiples.data.CIT[i] + ', ' + multiples.data.ST[i] + '</a>'
  • Just before the pages jumps (if one result), the drop-down shows for a split second. Added return; after the location.href to stop the processing.

 

 


Stephen Lloyd 11/17/2010