Dart/Polymer binding object attributes of a list - data-binding

I am trying to bind to the attributes of objects in a list. The list is made observable by using toObservable. Now I bind all the elements with polymer. Works fine. If a add an object to the list the update works also fine. But there is no update if the attributes of the objects in the list is changed. How can I achieve this?

I think you miss extends Object with Observable of the class declaration and/or the #observable annotation of the property declaration as shown below:
class YourListItem extends Object with Observable {
#observable aProperty;
}
If this doesn't help please provide the code of the objects you put into the list in your question.

Related

How can i make an object unmodifiable in flex

I am having a configuration object in my flex3.5 application. I want that object to be unmodifiable so that no one can change any property in it once it is created.
If you're talking about a generic Object, it's impossible since it's dynamic. What you want to do is create a class that has only 'getter' functions and every property is specified in the constructor.
If you want to have it still bindable, look at my blog post about bindable read-only properties.
Use get/set methods. There is can be two strategies:
Private variables are initialized within class itself and every private variable has public get-method which makes public field read only.
If you need to set values from outside you should create set-methods and throw an error if value already set.

Getting the target when using bindable getter in flex

I have the following files:
model.as
clint.mxml
in clint.mxml I have the following line:
<s:Group id='clint1' x="model.locationX">
...
in the model.as I have a getter:
[bindable(event="locationXChanged"))
function get locationX () : int {
return ...
}
My problem is that I need to know within the getter locationX that the id of the object that is getting the id is clint1 (The object id in the mxml).
The result of a getter should not depend on which object it is called from. I guess your getter should not be a getter and should maybe take a clintId as argument.
You can use this to refer to the current component. You can use 'this.id' to find out the component's name. More info on id property.
However, I'm getting mixed signals from your question and the question's title. Are you asking for the id of the binding target inside the binding source? Implementing that would add dependencies to your components thus harming their ability for reuse.

HowTo access correct data inside an AdvancedDataGridColumn-ItemRenderer?

How can I access the specific .data (based on its dataField) inside an AdvancedDatagridColumn-ItemRenderer instead retrieving the whole data for the parent AdvancedDataGrids dataprovider?
Any idea?
Many thanks...
In an itemRenderer, your dataProvider's object is passed in to the data property of the itemRenderer. Your itemRenderer will need to implement the IDataRenderer interface
http://livedocs.adobe.com/flex/3/langref/mx/core/IDataRenderer.html
Most Flex Framework Components already implement this interface.
The way that the DataGrid component works internally is to call an itemToLabel function ( http://livedocs.adobe.com/flex/3/langref/mx/controls/listClasses/AdvancedListBase.html#itemToLabel() ) to figure out the label to display. This function will look at the dataField and dateFunction and return a string representing your item.
The results of this function are passed into the itemRenderer as part of the AdvancedDataGridListData class. Take a look at the label property:
http://livedocs.adobe.com/livecycle/8.2/programLC/common/langref/mx/controls/advancedDataGridClasses/AdvancedDataGridListData.html
You can also use DataGridListData.owner to access the dataField directly, although that would be an unusual approach.

Extending Flex FileReference class to contain another property

I want to extend the FileReference class of Flex to contain a custom property. I want to do this because AS3 doesn't let me pass arguments to functions through event listeners, which makes me feel sad, so I need this property to exist on the event target, so I can access it.
I also want to be able to cast extant FileReference objects to this class without any fuss. I have:
var fr:SmxFR = e.target as SmxFR
and I want that to work; right now it just returns null.
A blank, newly instantiated SmxFR object has the extended property in place, but all of its inherited properties and objects return Error: Error #2037: Functions called in incorrect sequence, or earlier call was unsuccessful.
This is the class I am using, SmxFR.as:
package
{
import flash.net.FileReference;
public class SmxFR extends FileReference
{
public var housenum:String = "";
public function SmxFR()
{
super();
}
}
}
Kept it as straightforward as I could, really. Can someone please help me figure this out? Thanks.
Edit:
Per request, this is the instantiation which results in the aforementioned error in all inherited objects:
var fr:SmxFR = new SmxFR();
I get living handle property from that, and all other (that is, inherited) properties throw Error #2037.
So, maybe what I want to do is going to require overriding FileReferenceList? If the original objects must be instantiated to SxmFR, that's what I'll have to do, since I'm using FRL to allow the user to select multiple files at once. Are you guys sure there is no way to fast from a FileReference to my class?
You can totally pass objects via event listeners, it's just done in a specific way. I'd learn to do it correctly, rather than trying to extend a core library which could cause you problems later if you make a small mistake.
My solution: instead of extending FileReference, extend Event and add your properties to that.
var myEvent:MyExtendedEvent = new MyExtendedEvent();
myEvent.myCustomProperty = myValue;
dispatchEvent(myEvent);
Then in your handler you just write:
function myEventHandler(e:MyExtendedEvent):void {
trace(e.myCustomProperty);
}
Much more painless to go down this road! The added benefit is that if any other Flash Developer anywhere ever looks at your code they're not going to get hit in the face with a non-standard customized FileReference. :)
When e.target is instantiate as FileReference you can't cast it to SmxFR because it's not in the line of inheritance. In the other way you can a SmxFR Object to FileRefernce.
Extending FileReferenceList is not going to be helpful. FileReferenceList.browse() method creates an array of FileReference object when user selects multiple files - that happens internally (may be in its private methods) and you cannot change that behavior and force it to create SxmFR objects instead. Use custom events as Myk suggested.
This article talks about Sound objects, but may be that's applicable to FileReference objects too. May be you cannot reuse them. Post the code where you use the SmxFr class and get the said error.

Can I define multiple itemRenderers in a Flex / Actionscript list

Basically I want to override some function in the flex/actionscript list class which creates a new ItemRenderer and passes it the required data ready to be displayed. I need to do this because I wish to show a different renderer based on the type of data being displayed. Is there such a function?
I don't really want to pass the list a single itemRenderer which calls its addChild function depending on the type of data it has - It just doesn't seem right...
Thanks.
You should override public method createItemRenderer(data:Object):IListItemRenderer of ListBase class (and List, which extends ListBase)

Resources