Welcome to Kap Lab Store

Topic "Autocomplete Error"


Items 1 to 10 of 12 total

per page
Page:
  1. 1
  2. 2
Hello All

I'm using an Autocomplete component that has for dataprovider an ArrayCollection that is filled from an XML file.
This ArrayCollection has multiple fields, so in my Autocomplete component I added property labelfield.
Autocompletation works good, but when i click on the X button for delete my entry, my program crashes with following error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

I made some tests, and I think there's something wrong on property labelfield.

Someone can help me?
Posted : 04 January 2012 16:59
Can you post a short sample of your app reproducing the issue?
Posted : 04 January 2012 17:01
XML file has this structure:
<id>50011</id>
<gw>gl100</gw>
<name>Shopping Day</name>
<zip>31033</zip>
<country>Italy</country>
<active>yes</active>
<map></map>
<voip>n</voip>
<group>f</group>
<sirac></sirac>
<perc></perc>
<sloc></sloc>

I fill Arraycollection and add dataprovider with following sintax:

arrayLocation=new ArrayCollection();
arrayLocation.source = dropListDb.toArray();
listLocation.dataProvider = arrayLocation;

where dropListDb is an ArrayList that contain XML data

Autocomplete tag is following:

<ui:AutoComplete id="listLocation" x="33" y="38" width="362" labelField="name" />
Posted : 04 January 2012 17:21
Sorry but I need more details to help you.

How data are stored in the ArrayList?
Is the XML data converted to some value object?
Posted : 05 January 2012 17:24
The code is:

[Bindable]
private var dropListDb:ArrayList;

public function accountingService():void {
var contaLoc: int = 0;
dropListDb=new ArrayList();
for (contaLoc = 0; contaLoc < LocationService.lastResult.LOCATIONS.Location.length ; contaLoc++)
{
dropListDb.addItem(LocationService.lastResult.LOCATIONS.Location.getItemAt(contaLoc));
}
var arrayLocation:ArrayCollection;
arrayLocation=new ArrayCollection();
arrayLocation.source = dropListDb.toArray();
listLocation.dataProvider = arrayLocation;
}

<ui:AutoComplete id="listLocation" x="33" y="38" width="362" labelField="name" />

My XML file has this structure:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<LOCATIONS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Location>
<id>50011</id>
<gw>gl100</gw>
<name>Shopping Day</name>
<zip>31033</zip>
<country>Italy</country>
<active>yes</active>
<map></map>
<voip>n</voip>
<group>f</group>
<sirac></sirac>
<perc></perc>
<sloc></sloc>
</Location>
</LOCATIONS>

I don't make other operations on XML data.
Posted : 09 January 2012 11:21
Looks like there is a bug somewhere in the component.
I haven't found out what's happening really yet (it works fine with our demo)
In the mean time, you can add this simple fix :

In the commitProperties of AutoComplete.as , change this code
if (_selectedItemChanged)
{
	_selectedItemChanged = false;
	text = getDisplayString(_selectedItem);
	textDisplay.selectRange(text.length, text.length);
	dispatchEvent(new AutoCompleteEvent(AutoCompleteEvent.SELECT));
}
 
by this code :
if (_selectedItemChanged)
{
	_selectedItemChanged = false;
	if (_selectedItem)
	{
		text = getDisplayString(_selectedItem);
		textDisplay.selectRange(text.length, text.length);
		dispatchEvent(new AutoCompleteEvent(AutoCompleteEvent.SELECT));
	}
}
 
and it should work.

Once the bug clearly identified, I'll update the download package
Posted : 09 January 2012 14:26
Thanks for your answers!
I'm a flex beginner, how can I edit "AutoComplete.as"?
Posted : 11 January 2012 11:42
When you download Klovis, you get the compiled lib (SWC) and the source code of the components (in a src folder) for each of the 4 Klovis libraries

AutoComplete can be found in the src folder of the klovis-flex4-ui.zip file. (src/fr/kapit/flex/ui/spark/autoComplete)

Copy that file in your project, in a new package. I suggest you rename it FixedAutoComplete and add the changes I've talked about in my previous post
Posted : 11 January 2012 11:48
Just today i could try your suggestions.
I followed your instructions, but when I run application, I have the same Error.

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at fr.kapit.flex.ui.spark.autoComplete::AutoComplete/getDisplayString()[E:\jenkins\jobs\Klovis\workspace\klovis-flex\klovis-flex4-ui\src\main\flex\fr\kapit\flex\ui\spark\autoComplete\AutoComplete.as:895]
at fr.kapit.flex.ui.spark.autoComplete::AutoComplete/commitProperties()[E:\jenkins\jobs\Klovis\workspace\klovis-flex\klovis-flex4-ui\src\main\flex\fr\kapit\flex\ui\spark\autoComplete\AutoComplete.as:575]
at mx.core::UIComponent/validateProperties()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:8209]
at mx.managers::LayoutManager/validateProperties()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:597]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:813]
at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1180]


It seems that the new FixedAutocomplete.as has not seen by the libraries.
Posted : 13 January 2012 11:53
Strange.

Can you test your application with this new SWC?
Posted : 16 January 2012 11:41

Items 1 to 10 of 12 total

per page
Page:
  1. 1
  2. 2