views:

1286

answers:

3

I'm working in a multi-language application using ResourceBundle in Flex 3. I'm displaying data in a DataGrid and defined DataGridColumn headerText like this

headerText="{localizedHeaderText('LABEL_USER_NAME')}

this function returns the localized label for the username, but when I dynamcally select another language evertying gets refreshed but the headerText labels?

Any thoughts?

Thanks

+3  A: 

Unless you make the localizedHeaderText method bindable, the binding will never be re-evaluated since it does not know about the change event of the resourceManager.

Assuming you are in a UIComponent subclass, you'll need to do the following:

  1. override resourcesChanged and dispatch a custom event
  2. add [Bindable(event="customEvent")] above the method

Sample code:

override protected function resourcesChanged():void {
    super.resourcesChanged();
    dispatchEvent(new Event("localeChange"));
}

and

[Bindable(event="localeChange")]
public function localizedHeaderText(key:String):String {
    return resourceManager.getString('resources', key);
}
Christophe Herreman
A: 

Hey thanks alot...it really worked. I was stuck with the same problem and came through this post and it was a great relief to get the exact working answer.

Thanks again

+1  A: 

Hi,

I run into the same problem but I only use a straight binding tag. Your solution works perfectly but I am still puzzled why a straight binding would not work.

<mx:Binding
    source="resourceManager.getString('resources', 'id')"
    destination="id_col.headerText"
/>

what would I need to do for it to bind properly when I change locale?

Thanks for your help,