views:

23

answers:

2

Hi,

as I probably do not describe the problem in the right terms, I was not able to get an answer with google. Please excuse!

In the following code, I would like to replace 'hardcoded' identifier COMMENT with the variable editedField. How to do that?

var editedField:String = event.dataField;
if (model.multipleProcessingData[i][editedInformationProductNO].COMMENT != null{
    ...
}
A: 

var editedField:String = event.dataField;

if (model.multipleProcessingData[i][editedInformationProductNO][editedField] != null{

...

}

www.Flextras.com
Thanks a lot, I was trying with a point in between, whereas the syntax is (like) for multidimensional arrays.Thumps up, thanks!
Werner
A: 

Make sure you wrap this in try/catch block for NPE's, as you'll eventually find one with this many [] accessors.

A better, more OOP, would be to have an accessor function on your model that you can pass your data to: model.getEditedField(i, editedInformatioNProductNO, editedField)

This will make it easier to troubleshoot and add good error messages to your app if things don't turn out like you expected.

Dusty J
you would any operation on a dataprovider, even adding/removing items, manage through getters and setters?
Werner
Absolutely, though not necessarily through getters and setters... you want to separate the view and logic as much as possible. The 'view' should not be modifying the model directly. In larger apps we use MVC architectures, like Cairngorm, Swiz, Mate, etc. You always have to refactor your code eventually. The idea is to make sure that if you refactor your data structure, your view doesn't break. Accessing and modifying data through function calls is the first and easiest step to having maintainable code.
Dusty J