Mr. Williams,
Genius! This makes sense because the Object needs to have an Identifier the
DataProvider knows about. If I implement the IUID, it knows.
I was banging my head against my desk because this was working when I
used a DataService to bind to a java adaptor DataProvider. I guess the
DataService automatcally wraps the returned object with the IUID (or
equivilent) because I define an identifier in the flex-data-service.xml:
<destination id="person">
<adapter ref="java-dao" />
<properties>
<metadata>
<identity property="personId"/>
</metadata>
...
But if my object is not bound to a DataService, I need to implement the IUID interface. Do you know if this is going to be in the final release?
thanks,
-JB
--- In [email protected], "Geoffrey Williams" <[EMAIL PROTECTED]> wrote:
>
> The return type of selectedItem is Object, so he's casting to the correct
> type.
>
> For the time being I believe your ResourceVO has to be made dynamic or
> implement the IUID interface.
>
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of Ted Patrick
> Sent: Wednesday, April 12, 2006 2:48 PM
> To: [email protected]
> Subject: RE: [flexcoders] programatically assigning an ArrayCollection as
> the DataProvider bug...
>
> JB,
>
> Why are you casting dg.selectedItem when it is already is a ResourceVO? The
> selectedItem value is the item passed into the addItem method.
>
> ArrayCollection has events to support updating a view (DataGrid, List,
> ComboBox). This can be accessed through the component itself or via the
> dataProvider property.
>
> Try this:
>
> private function init():void{
>
> var obj1:ResourceVO = new ResourceVO();
> obj1.value = "foo-0";
> obj1.key = "bar-0";
> dg.addItem( obj1 );
>
> var obj2:ResourceVO = new ResourceVO();
> obj2.value = "foo-1";
> obj2.key = "bar-1";
> dg.addItem(obj2);
>
> var obj3:ResourceVO = new ResourceVO();
> obj3.value = "foo-2";
> obj3.key = "bar-2";
> dg.addItem(obj3);
> }
>
>
> When dataProvider is set, the passed object is wrapped by an ArrayCollection
> depending on what is passed. If an Array is passed, this becomes the
> 'source' property of the ArrayCollection. You may be seeing a side effect of
> an ArrayCollection being passed into an ArrayCollection via the dataProvider
> set operation. By default, the dataGrid already has a ArrayCollection and
> using addItem on the DataGrid (dg) will make things simpler internally. I
> also do not think that the "dataObj" variable needs to be [bindable] here
> and might be a source of an error.
>
> ArrayCollection is a funky class as it extends Proxy via ListCollectionView.
> Proxy allows the entire DataProvider API to be a fa�ade allowing control
> over iteration via the Proxy.nextName, Proxy.nextNameIndex, and
> Proxy.nextValue at a low level.
>
> My gut feel is that the code can be simpler and accomplish identical
> results.
>
> Cheers,
>
> Cynergy Systems, Inc.
> Theodore Patrick
> Sr. Consultant
> [EMAIL PROTECTED]
> tel: 1.866.CYNERGY
> http://www.cynergysystems.com
>
>
>
> ________________________________________
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of box110a
> Sent: Wednesday, April 12, 2006 2:08 PM
> To: [email protected]
> Subject: [flexcoders] programatically assigning an ArrayCollection as the
> DataProvider bug...
>
> I didn't see this in the known issues. but I'll attempt to explain whats
> going on:
>
> Here is my Code (i'll explain the bug at the end):
> DGTest.mxml
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
> layout="absolute" creationComplete="init();"
> pageTitle="DataGrid Test">
> <mx:Script>
> <![CDATA[
> import mx.utils.ArrayUtil;
> import com.crap.vo.ResourceVO;
> import mx.collections.ArrayCollection;
>
> [Bindable]
> public var dataObj:ArrayCollection;
> [Bindable]
> public var objTemp:ResourceVO = new ResourceVO();
>
> private function init():void{
> dataObj = new ArrayCollection();
>
> var obj1:ResourceVO = new ResourceVO();
> obj1.value = "foo-0";
> obj1.key = "bar-0";
> dataObj.addItem(obj1);
>
> var obj2:ResourceVO = new ResourceVO();
> obj2.value = "foo-1";
> obj2.key = "bar-1";
> dataObj.addItem(obj2);
>
> var obj3:ResourceVO = new ResourceVO();
> obj3.value = "foo-2";
> obj3.key = "bar-2";
> dataObj.addItem(obj3);
>
> dg.dataProvider = dataObj;
> }
>
> private function selectRow():void{
> objTemp = ResourceVO(dg.selectedItem);
>
> }
>
> ]]>
> </mx:Script>
> <mx:HBox width="90%" height="90%" horizontalCenter="0"
> verticalCenter="0">
> <mx:Panel layout="absolute" height="50%" width="50%">
> <mx:VBox width="443" height="90%" horizontalCenter="1"
> verticalCenter="-1">
> <mx:DataGrid id="dg" width="100%" height="100%"
> change="selectRow();"
> editable="true"
> >
> <mx:columns>
> <mx:DataGridColumn headerText="Key"
> dataField="key"/>
> <mx:DataGridColumn headerText="Value"
> dataField="value"/>
> </mx:columns>
> </mx:DataGrid>
> </mx:VBox>
> </mx:Panel>
> <mx:Panel width="50%" height="50%" layout="absolute">
> <mx:Form x="10" y="10" height="156" width="445">
> <mx:FormItem label="Key:">
> <mx:TextInput id="txtKey" data=""/>
> </mx:FormItem>
> <mx:FormItem label="Value:">
> <mx:TextInput id="txtValue" data=""/>
> </mx:FormItem>
> </mx:Form>
> </mx:Panel>
> </mx:HBox>
> </mx:Application>
>
> ResourceVO.as
> package com.crap.vo {
> import com.crap.mvc.vo.ValueObject;
> import mx.resource.Locale;
> import mx.controls.listClasses.BaseListData;
> import mx.controls.listClasses.IDropInListItemRenderer;
>
> import mx.data.IManaged;
> import mx.data.utils.Managed;
> import mx.core.mx_internal;
>
> [Bindable]
> public class ResourceVO implements ValueObject{
> public var key:String = "";
> public var value:String = "";
> public var locale:Locale = new Locale("eng_us");
>
>
> }
> }
>
>
>
> The Issue:
> When I view this application, it works as expected: it shows the datagrid
> with the three items and when I click on it, the fields to the right are
> populated. However, the blue selection highlight doesn't move off of the
> last item in the list! I have also sceen this issue in a ComboBox.
>
> Any ideas as to why this is happening?
>
> -JB
>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

