Select to view content in your preferred language

AutoComplete on textInput

517
2
04-15-2010 10:07 AM
CaseyBentz
Frequent Contributor
I have been working on getting the Yahoo Astra AutoCompleteManager to work.  I have an httpService that runs and populates the dataprovider for the AutoCompleteManager.  This all works perfectly, except that when I get the pop up to open, and the list is long enough to have the vertical scroll bar appear, and type end/home, I get this error message.  Otherwise, this tool works perfect.  I would like to listen for the mouse click event on an item, but other than that it seems pretty good.  Any help would be great.

Casey

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at mx.controls.listClasses::ListBase/itemRendererToIndex()
at com.yahoo.astra.mx.managers::AutoCompleteManager/keyDownHandler()
Tags (2)
0 Kudos
2 Replies
TabrezQuazi
Emerging Contributor
Casey,

Can you post the code, that will help us understand what the exact problem is..
One other reason for the exception could be that the dataprovider has a null in the list.
Add a filterFunction to remove any null values in the dataproviders list.

Thanks,
Tabrez Nadeem.
0 Kudos
CaseyBentz
Frequent Contributor
I have attached my code and the SQL string from my web service.  I added the is not null, and it did not help.  So, I assume that I do not have any null values.  

I also tried to use the same textInput for each of my search options, I do not want the autocomplete enabled when the other search options are chosen.  I could not get it to work, so I went with a second textInput and this works.  I do not like it but it works. 

Also, I cannot get the pop up list to be sorted alphabetically, I would have thought that if the returned XML was in alphabetical order, the list would be too.

SELECT DISTINCT SUBDIVNAME FROM GIS.SubdivisionBoundaries WHERE SUBDIVNAME <> '' AND SUBDIVNAME <> ' ' AND SUBDIVNAME IS NOT NULL ORDER BY SUBDIVNAME

<?xml version="1.0" encoding="utf-8"?>
<mx:FormItem xmlns:mx="http://www.adobe.com/2006/mxml" label="Select Search Type:" styleName="BannerStatus" xmlns:yahoo="http://www.yahoo.com/astra/2006/mxml">
<mx:Script>
  <![CDATA[
   import com.events.SearchEvent;
   import com.model.Model;
  
   private function init():void{
    if (searchType.selectedValue == "Subdivision"){
     textSearch.visible = false;
     textSearch.includeInLayout = false;
     subSearch.visible = true;
     subSearch.includeInLayout = true;
     subSearch.setFocus();
    }
    else{
     textSearch.visible = true;
     textSearch.includeInLayout = true;
     subSearch.visible = false;
     subSearch.includeInLayout = false;
     textSearch.setFocus();
    }
   }
  ]]>
</mx:Script>
<mx:Binding source="textSearch.text"
  destination="subSearch.text"/>
<mx:Binding source="subSearch.text"
  destination="textSearch.text"/>
<yahoo:AutoCompleteManager id="autoComplete"
  dataProvider="{Model.instance.subdivisionXML.subdivision}"
  labelField="SUBDIVNAME"
  target="{subSearch}"
  minCharsForCompletion="4"
  wordWrap="true"/>
<mx:RadioButtonGroup id="searchType"/>
<mx:HBox width="100%" height="100%">
  <mx:RadioButton groupName="searchType" label="Service Point" styleName="BannerStatus" selected="true" click="init();"/>
  <mx:RadioButton groupName="searchType" label="Gisonumber" styleName="BannerStatus" click="init();"/>
  <mx:RadioButton groupName="searchType" label="Fuse or Switch" styleName="BannerStatus" click="init();"/>
  <mx:RadioButton groupName="searchType" label="Workorder Number" styleName="BannerStatus" click="init();"/>
  <mx:RadioButton groupName="searchType" label="Subdivision" styleName="BannerStatus" click="init();"/>
  <mx:TextInput id="textSearch" width="200" styleName="TextInput"
   enter="dispatchEvent( new SearchEvent(searchType.selectedValue.toString(), textSearch.text, SearchEvent.SEARCH_EVENT))"
   creationComplete="init();"/>
  <mx:TextInput id="subSearch" visible="false" includeInLayout="false" width="200" styleName="TextInput"
   enter="dispatchEvent( new SearchEvent(searchType.selectedValue.toString(), textSearch.text, SearchEvent.SEARCH_EVENT))"
   creationComplete="init();"/>
  <mx:Button label="Search" click="dispatchEvent( new SearchEvent(searchType.selectedValue.toString(), textSearch.text, SearchEvent.SEARCH_EVENT))" styleName="Button"/>
</mx:HBox>
</mx:FormItem>
0 Kudos