I18n and dataprovider

Hello

I'm trying to implement the internationlization for an application. The language must be changed during execution that is why I use the functionality of flex's ResourceManager. My problem is that some of our widgets app like comoboxes using dataprovider to be filled. If I change the language these widgets are not updated. Here is a code example:

< mx:ComboBox id = "combo" dataProvider = "{comboArray}" / >

the dataprovider is initialized in the method view onApplicationComplete


comboArray = [{label: resourceManager.getString ('language', 'form.value1.label'), data: 'test1'},]
[{label: resourceManager.getString ('language', 'form.value2.label'), data: 'test2'}] ;

Can someone give me a clue how to solve this problem or best practices?

Kind regards

Hi mwoodpecker,

When you change the language of the application... try to rebuild the table comboArray and reset the dataprovider for your

ComboBox.

This will solve the problem.

Thank you

Jean Claude

Tags: Flex

Similar Questions

  • Control tree and dataprovider XML

    Hello

    I am trying to get this xml file ( http://mitjafelicijan.net/test.xml ) working with my tree control in my Flex application and may not know how exactly to do this.

    What is my Flex code

    < mx:Tree left = "0" top = "0" low = '0' showRoot = "true" id = "trvTreeview" right = "0" > < / mx:Tree >

    and my AS code is this

    var tmp:XML = XML (event.target.data);
    trvTreeview.dataProvider = tmp.node;

    I get this result

    http://mitjafelicijan.NET/tree.PNG

    The default data descriptor will see any child node as a child and claim that this node is a folder.  If the xml node uses attributes like this:

    Then there is no of child nodes.  However, if you cannot change the structure of the XML, you can create a custom TreeDataDescriptor that is smarter about hasChildren()

    Alex Harui

    Flex SDK Developer

    Adobe Systems Inc..

    Blog: http://blogs.adobe.com/aharui

  • The definition of dataProvider programmatically causes null reference

    I am trying to bind a drop-down list box to a list of countries via a HTTPService which returns xml code. If I set the dataProvider and declaratively labelField properties in the mxml, then it works fine. However, if I try to set it programmatically in the method that is called after the called HTTPService returns, then I get "TypeError: Error #1009: cannot access a property or method of a null object reference."

    Here is the dataServiceResult method:

    [Bindable]
    private var _lookupData:XML;

    public void dataServiceResult(event:ResultEvent):void
    {
    _lookupData = event.result as XML;

    cboCountry.dataProvider = _lookupData.countries.country;
    cboCountry.labelField = "@name";
    }

    This causes the above error. However, if I have the last two lines of the method in comment and change the combo box return to resemble what follows, then it works fine:

    < mx:ComboBox id = "cboCountry" styleName = "RequiredFieldLabel".
    dataProvider = "{_lookupData.countries.country}" labelField="@name" "
    change = "countrySelected ()" >
    < / mx:ComboBox >

    Any ideas? Declarative binding will work in this particular situation, but I have several other cases where I need binding programmatically to xml, so I need to get this script working. Thanks in advance for any help!

    Aaron

    The simplest way around this is to link the labelField and dataProvider to a variable or a get/set accessor, and then set the variables (or the Set accessor) in the result handler.

    What is happening is that the combo box has not been instantiated in the place in which you try to set the values, so the null pointer.

  • How to charge the screen when changing languages in JavaFX 2?

    I am a beginner with javaFX and need to change the language of the screen... but I have no idea how to do to recharge the screen when the language has been changed. The application has a button where to have the language available. I just want to refresh screen when the user changes language.

    Here is the start method to show the scene.

    @Override

    public void start (steps) throws exceptions

    {

    Stage = this.stage;

    Locale locale = Locale.getDefault ();

    Rb ResourceBundle = ResourceBundle.getBundle ("resources/Label", local);

    loader = new FXMLLoader (getClass () .getResource ("FXMLDocument.fxml"), rb);

    root = (Parent) loader.load().

    FXMLDocumentController controller = loader.getController ((FXMLDocumentController));

    controller.setMain (this);

    scene = new Scene (root);

    stage.setScene (scene);

    internship. Show();

    }

    Here is the function to change the language (in the same class with start function), the rb is the new ResourceBundle:

    public void refresh (ResourceBundle rb)

    {

    change the language here

    }

    1. I don't want to use the resourceBundle to get the value in the resource file, and set the label in a scene of one.like following:

    this.btnLabel.setText (rb.getString (key.test));

    ...

    2. I don't want to reload the scene as follows:

    public void refresh (ResourceBundle rb)

    {

    VR;

    {

    loader = new FXMLLoader (getClass () .getResource ("FXMLDocument.fxml"), rb);

    root = (Parent) loader.load().

    scene.setRoot (root);

    FXMLDocumentController controller = loader.getController ((FXMLDocumentController));

    controller.setMain (this);

    }

    catch (exception Err)

    {

    err.printStackTrace ();

    }

    }

    While we have a solution to just define the resourceBundle and recharge the easier scene?

    Thank you and best regards!

    773846 wrote:

    JAVAFX isn't that kind of solution (more efficient and automatic)?

    No and nor Swing or AWT (no idea for SWT): whenever you manually change the value of all labels autour (or build a custom system to do as suggested). The easiest way that most of the app use is simply to save the language in preferences and then ask the user to restart the application. So when the computer reboots, the app is full new regional settings. On the change of the fly is another matter.

    Note: there is no FXML binding as far as i18n and text labels are concerned. You can just describe them as being located by using the '%' symbol, and at load time, the FXMLLoader has made an extra effort to replace anything out of all values (see the method resolvedPrefixedValue() in the class FXMLLoader source code simply call resources.getString ())... and that's all. There is more no link between controls text properties and the bundle once finished loading (and that's why you can replace everything that follows when in the controller when you want).

    Another option would be to create your own custom FXMLLoader keeps the autour bundle and create links to i18n labels at load time.,.

  • How to get the ValueObject that represents a row in a DataGrid, attached screenshot

    DataGrid.jpeg

    Hello

    I'm displaying the data in the DataGrid control by using the dataField and dataProvider as ArrayCollection collection attributes.

    It's my value object representing a row of DataGrid


    public class User
    {

    public var UName:String;
    public var Pwd:String;
    }


    On the clcik on the line in the DataGrid control, I am able to go read the elements of the cell using DatagridId.selectedItem.UName.

    Is it possible to get all of the user object that represents this line.
    I'm sorry, that if the issue is not comprehensible, here basically I want to get the whole VO of this line in the DataGrid control.

    Thanks in advnace

    Hi Kiran,

    Try to use something like below...

    var userVO: User = DatagridId.selectedItem as a user;

    Thank you

    Jean Claude

  • How the variable in the data area?

    in the XML file, I have

    < list >

    < event_id > EMB10 < / event_id >

    < col1EMB10 > ALL < / col1EMB10 >
    < col2EMB10 > 0 < / col2EMB10 >

    HON < col1EMB10 > < / col1EMB10 >
    < col2EMB10 > 1 < / col2EMB10 >

    < / list >

    < list >

    < event_id > EMB11 < / event_id >

    HON < col1EMB10 > < / col1EMB10 >
    < col2EMB10 > 1 < / col2EMB10 >

    < / list >


    I want the datagrid control to display above value.

    When the drop-down list select event_id EMB10, the data area should be as below
    dataField = "col1EMB10."
    dataField = "col2EMB10."

    I did, but they do not work:

    dataField ="

    col1 | "| {cboActivities.selectedItem.event_id} |' "

    dataField ="col2 |" | {cboActivities.selectedItem.event_id} |' "

    Pleas help!
    Thank you in advance!

    It is also as expected.

    You have to the first grid:

         ALL THE
    0
    HON
    0
    Of course, you can say you want 2 lines in the result and it looks like this:
    ALL THE | 0
    HON | 0
    But it is unclear what col2YUD09 should be with what col1YUD09. In this example, you have two 0, so there is no difference. If you have
    ALL THE
    1
    HON
    0
    What should be the result?
    ALL THE | 1
    HON | 0
    or
    ALL THE | 0
    HON | 1
    ???
    There is no any order in xml!
    Data should be as
    ALL THE

    1

    HON
    0

    And dataProvider - cboActivities.selectedItem.item

  • ViewStack with LinkBar in the other component.

    Hi people.

    I start in Flex, and I have a few questions.

    One of them is the following: How can I implement a ViewStack where buttons navigate through it in the other component?

    Something like this: I have a C1 container. A C1 C2 (the LinkBar) and C3 (the ViewStack). How controls C2 C3?

    I try to use ActionScript and dataprovider. Something like this:

    < mx:Script >

    <! [CDATA]

    [Bindable]

    public var dataP: String;

    []] >

    < / mx:Script >

    <!-...->

    < mx:LinkBar dataProvider = direction "{dataP}" = "vertical" / >

    And my other component (C1), which is called:

    < id for components: C2 = "c2" width = "10%" dataP = "viewStackHome" / >

    < mx:ViewStack id = "viewStackHome" >

    < components: BoxHome id = "boxHome" / > <! - vai pra esse com o home as fica em cima - >

    < components: PainelListaDeContatos id = "painelDeContatos" / > <!-Alexandre of "Meus is"->

    < / mx:ViewStack >

    If I am sendind the ViewStack id before you create it?

    Thank you!

    And ignore my bad English. I'm not very used to write technical things (and I'm not very fluent).

    But it does not work.

    The answer is todo what follows in your Menu.mxml:

    [Bindable] public var myDataProvider:ViewStack;

    --------------------------------------------------------------------------

    http://www.Adobe.com/2006/mxml"xmlns:components ="components.*">
     
        Import mx.containers.ViewStack;

    [Bindable] public var myDataProvider:ViewStack;
    ]]>
     
     


    http://www.Adobe.com/2006/mxml '.
    "xmlns:Components =" * ">
     
     
       
         
       

       
         
       

     

  • Populating a list from a Class... How?

    It seems simple (in fact... it used to be, but I'm now trying to figure out how do it in AS3...)

    I have a remote access script that reads a list of customers from a database via Flash remoting. I had this part works fine. He reads the database and I receive the data in a table. It then returns the table in a command trace() without any problem. I can't fill the list component that I hit against the stange however. Now I can get it to do this whole process outside of a class (works perfectly), but once inside the class,... it can not / will not write the data in the table to the list.

    I've done a lot of research and it seems that nobody asked that specific question. I found similar topics, but which is discussed as a solution doesn't seem to work (including an addChild method (array)). It seems, ludacris, if not totally redundant, having to declare, within a class, an instance of something that is already placed on the stage. Is that what all of a class MUST be generated from this class or can you have the instances already placed on the scene and waiting for classes to interact with them? What I'm missing here?

    (BTW - myList is the name of the instance of the List component, which is sitting on the stage, waiting to be filled.)
    -1120: access of undefined property myList.

    Thanks for the help and information! After reading your posts and doing a lot of trial and error, I finally got (and understand)! I was able to dump the data in the table into a data provider. I also wanted access to the table I did from anywhere in the application as well. So my main hold-up was that I was calling new array and DataProvider new within the class method. I moved those out of the area of class method and put between the class declaration and the constructor. These variables variable instance compared to local variables was done and they started to work as it should, publicly. I now have access to my table everywhere and I was able to dump the data in the object of waiting list already on the stage by calling it from the main timeline:

    import com.exade.working.getClientList;
    var clientList:getClientList = new getClientList();
    myList.dataProvider = clientList.myData;

    The class file now looks like this:

  • Plugin using the html bridge with DataProvider which includes DataProviderAdapter and PropertyProviderAdapter

    Hello

    We have extended our plugin to include views that use the html Bridge.

    The first step was to display the data on our custom types. Applications range from the gui - to the DataAccessControlller as seen in the samples of chassis.  Then a RequestSpec is generated and sent to the dataService:

    dataService.getData (requestSpec).

    The dataServices then forwards the request to our DataProviderAdapter - as in the example. Everything works fine.

    Now we want to rewrite some of the other views (for guests, vcenters etc.) to use the html Bridge as well, but these views use PropertyRequestSpecs for data.  These requests should be sent to the PropertyProviderAdapter - where all code wrote

    I tried something like the following:

    If (targetType is customType) - build a RequestSpec and send it to the dataService

    If (targetType == managedObjectType (as a host) - build a PropertyRequestSpec and send it to the dataService.)  This

    does not work, because the dataService only takes RequestSpecs as the parameter to GetData.

    I looked at the samples for vsphere and saw that they also make RequestSpecs and send them to the dataService.  These applications, however, do get sent to their PropertyProviderAdapter - and I have found no difference in the way in which the RequestSpecs were built.

    The difference between the 2 samples and my DataProvider, it is that I have both a DataProviderAdapter and a PropertyProviderAdapter in the same DataProvider.

    So the question is: is it possible to have the dataService send the request to the adapter is correct (or both) - based on the targetType?

    Thanks for any ideas

    Cathy

    The DataService interface is:

    public Response getData(RequestSpec request);
    

    RequestSpec has a picture of QuerySpec

    public QuerySpec[] querySpec;
    

    The QuerySpec a ResourceSpec and constraint:

    public ResourceSpec resourceSpec;
    
    public Constraint constraint;
    

    In the ResourceSpec you have PropertySpec

    public PropertySpec[] propertySpecs;
    

    In the PropertySpec you have the property names:

    public String[] propertyNames;
    

    Now after all this being said, if you have a PropertyProviderAdapter, who provides the 'foo' VirtualMachine type property, you must pass the DataService a RequestSpec with

    ObjectIdentityConstraint c = new ObjectIdentityConstraint();
    c.target = vmMor;
    c.targetType = "VirtualMachine";
    requestSpec.querySpec[0].resourceSpec.propertySpecs[0].propertyName[0]="foo";
    requestSpec.querySpec[0].constraint = c;
    

    Now when you pass this requestSpec, the DataService will build the PropertyRequestSpec and call your adapter.

  • drop-down list dataProvider and an object of value

    I am filling a dropdown menu with values that are stored in an object of value.   I'm pulling the values from the table of a database vai SQLite the SQLResult object and they come as an array of objects of value. This is exaclty what I want, so I refer to those within a property of my object model and shipping and the event carrying this table.   I place the array of objects of value in a collection of table as follows:

    var dropDownListValues:ArrayCollection = new ArrayCollection(event.foodCategoryList);
    

    Try to access it via a drop-down list lists dataProvider property as follows:

    foodCategory.FoodCategory_DropDown.dataProvider = dropDownListValues;
    

    My drop-down list then displays

    [object Object]
    [object Object]
    [object Object]
    [object Object]
    [object Object]
    [object Object]
    

    My dropDownListValues object has the following table:

    [0]
         Foodcatagory = "Grains"
         FoodCatagory_ID = 1
    
    [1]
         Foodcatagory = "Vegetables"
         FoodCatagory_ID = 2
    
    
    
    
    etc. all the way up to index 5
    
    
    

    How can I get the drop-down list to display only the Grains, vegetables... etc.?

    Thank you

    I had to search around for a few hours today on the same subject.

    Basically just set the labelField of the drop-down list the name of the field for its values

    foodCategory.FoodCategory_DropDown.labelField = "Foodcatagory";
    
  • The substitution of this dataProvider and FilterFunction

    I use a filterFunction for a dropdownlist control function. I am also replacing a dataProvider for this control. Here is a code fragment:

    private var _dataProvider:IList;
    override public function set dataProvider(value:IList):void 
              {
                   //if IList is ICollection view, done
                   if(value is ICollectionView)
                   {
                        super.dataProvider = value;
                   }
                   
                   //make IList into ICollectionView
                   if(value is IList)
                   {
                        super.dataProvider = new ArrayCollection(value.toArray());
                   }
                   _dataProvider = value;               
              }
              override public function get dataProvider():IList
              {
                   return _dataProvider;
              }
    

    I borrowed this code from the Internet.

    After that I added the code for the override of that function filterFunction does not filter the data the most. What I see is that the getter function returns the complete source of data and that is why the control displays the data of complete game and not filtered one.

    Any help?

    I think that you can just write .filterFunction instead of cast on XMLListCollection (subdivisions.dataProvider). and ensure that data providers can be related. including the bombers and the buyers. See the followign Url.

    http://userflex.WordPress.com/2008/04/14/bindable-getters-and-setters/

    change: you do collection ArrayCollection (subdivisions.dataProvider) .filterFunction after reading the code again once, I thought that it will work.

    Post edited by: saisri2k2

  • Problems using collection ArrayCollection as a DataProvider for trees and the menu bar, possibly bug?

    Hi guys,.

    I'm having some troble using a collection ArrayCollection as a DataProvider for a tree and a menu bar...

    I read some Adobe documents on this subject, and I read that two components read the dataProvider in the same way.

    but my current works of DataProvider well on the tree, but not on the MenuBar component...

    My dataProvider is an ArrayCollection collection of a custom class (which extends from ArrayCollection collection), and among its assets is a children's collection: ArrayCollection, so the hierarchy can be read correctly.

    When I use the component of the tree it works, but the menu bar do not display the branches...

    Can someone help me?

    Here's the function that create my dataprovider:


    private function fnFillDP (): void {}
    for (var i: int = 0; admResult.length > i; i ++) {}
    If (.nivel JV_MenuAdm (JV_AuxMenuAdm(admResult[i]).menuAdm [0]) == 0) {}
    var novoMenu:CL_ArrayMenu = new CL_ArrayMenu();
    novoMenu.idMenu = .idMenu JV_MenuAdm (JV_AuxMenuAdm(admResult[i]).menuAdm [0]);
    novoMenu.titulo = .titulo JV_MenuAdm (JV_AuxMenuAdm(admResult[i]).menuAdm [0]);
    novoMenu.parent = .parent JV_MenuAdm (JV_AuxMenuAdm(admResult[i]).menuAdm [0]);
    novoMenu.nivel = .nivel JV_MenuAdm (JV_AuxMenuAdm(admResult[i]).menuAdm [0]);
    novoMenu.ordem = .ordem JV_MenuAdm (JV_AuxMenuAdm(admResult[i]).menuAdm [0]);

    dataProvider.addItem (novoMenu);
    } ElseIf (.nivel JV_MenuAdm (JV_AuxMenuAdm(admResult[i]).menuAdm [0]) == 1) {}
    for (var j: int = 0; dataProvider.length > j; j ++) {}
    {If (CL_ArrayMenu(dataProvider[j]).idMenu == {JV_MenuAdm (JV_AuxMenuAdm(admResult[i]).menuAdm [0]) .parent})}
    var novoMenuChildren:CL_ArrayMenu = new CL_ArrayMenu();
    novoMenuChildren.idMenu = .idMenu JV_MenuAdm (JV_AuxMenuAdm(admResult[i]).menuAdm [0]);
    novoMenuChildren.titulo = .titulo JV_MenuAdm (JV_AuxMenuAdm(admResult[i]).menuAdm [0]);
    novoMenuChildren.parent = .parent JV_MenuAdm (JV_AuxMenuAdm(admResult[i]).menuAdm [0]);
    novoMenuChildren.nivel = .nivel JV_MenuAdm (JV_AuxMenuAdm(admResult[i]).menuAdm [0]);
    novoMenuChildren.ordem = .ordem JV_MenuAdm (JV_AuxMenuAdm(admResult[i]).menuAdm [0]);
    If (dp.length > 0) {}
    If (CL_ArrayMenu (dp.getItemAt (0)) .parent == novoMenuChildren.parent) {}
    dp.addItem (novoMenuChildren);
    } else {}
    DP = new ArrayCollection();
    dp.addItem (novoMenuChildren);
    }
    } else {}
    dp.addItem (novoMenuChildren);
    }

    CL_ArrayMenu (DataProvider [j]). Children = dp;
    break;
    }
    }
    }
    }
    tree.dataProvider = dataProvider;
    menu.dataProvider = dataProvider;
    }

    Sorry for the bad English...

    Hello

    You can try using xml as the dataprovider of the Menu bar instead of going for the Arraycollection collection.

    Thank you

    Roman

  • Problem with spark list and XML dataProvider

    I am VERY new to Flex so I'm probably doing something wrong, but I hope it means this will get a quick response.

    I use a list of spark related to a data provider. On the actions of the user, the list will be filtered. The problem I encounter is that when the xml result is one, she will eventually launch an error:

    Has no type constraint: cannot convert mx.utils::ObjectProxy to mx.collections.IList.

    Here is the code to reproduce the problem...

    Main.MXML

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application
     xmlns:fx="http://ns.adobe.com/mxml/2009" 
     xmlns:s="library://ns.adobe.com/flex/spark" 
     xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
     <fx:Script>
     <![CDATA[
      
     protected function singleItemButton_clickHandler(event:MouseEvent):void
     {    
      ItemService.send();    
     }
     protected function mutliItemButton_clickHandler(event:MouseEvent):void
     {
      var dataObject:Object = new Object();
      dataObject.multi = "yes";
      ItemService.send( dataObject );
     }
     ]]>
     </fx:Script>
    
     <fx:Declarations>
      <s:HTTPService    
       id="ItemService" 
       url="http://myserver/xml/itemXML.cfm" />   
     </fx:Declarations>
    
     <s:List id="theList" 
      x="60" y="29" width="200" height="251" 
      dataProvider="{ItemService.lastResult.items.item}" labelField="name"/>
    
     <s:Button x="77" y="287" label="Single Item" click="singleItemButton_clickHandler(event)"/>
     <s:Button x="172" y="287" label="Multi-Item" click="mutliItemButton_clickHandler(event)"/>
    
    </s:Application>
    

    itemXML.cfm

    <cfsetting showDebugOutput="No">
    <cfxml variable="result">
     <items>
            <item>
                <name>Item One</name>
            </item>
      <cfif isDefined('url.multi') AND '#url.multi#' EQ 'yes'>
                <cfoutput>
                <item>
                    <name>Item Two</name>
                </item>
              </cfoutput>
            </cfif>
       </items>
    </cfxml>
    <cfoutput>#result#</cfoutput>
    

    http://blogs.Adobe.com/aharui/2007/03/arraycollection_arrays_and_ser.html

  • need help with dataProvider and HTTPService result

    Hello

    I am following the tutorial from flickr http://labs.adobe.com/technologies/flexbuilder2/tutorials/# and a stumbling wrt the HTTPService. The example HTTPService has id = "service" and the "Search" button called "service.send ().
    The TileList is used to display the data and the dataProvider = "{service.result.rsp.photos.photo}". "

    In the example, the AutoComplete even showed that service responded to the result message, but
    This isn't the case for me. AutoComplete for me only shows 'resultFormat' as a possibility. Using
    result, I get the error:

    The result of the property possibly access not defined through a reference with static type mx.rpc.http.mxml:HTTPService. flickr1 flickr1.mxml line 11

    Am I missing something?

    Thank you

    Try 'lastResult' instead of result.

  • Component of Repeater with a DataProvider that spreads upward and changes its data

    Hey guys, I got a repeater than repeaters HSlider component.

    When my dataprovider changes, things as text = '{myAC [list.currentIndex] .name}' gives me the error: "Repeater is not enforcement."
    someone knows how to fix this?

    I ended up using repeater_instance.currentItem.varName and so forth instead of binding to the text property of a textField my collection Arraycollection (.varName myAC.getItemAt (repeater_instance).

Maybe you are looking for

  • I created a new library of more new playlists but cannot find the Library.xml file

    Hello I'm going to re - build my iTunes files from scratch, a kind of decennial event 'spring clean '. I have created a new library by using the command, click on application startup, and then began to rebuild new reading lists in the application. I

  • Automatic backups do not move under Windows 7

    FF support (https://support.mozilla.com/en-US/kb/Backing+up+and+restoring+bookmarks)said FF automatically creates backups of your bookmarks and saves the last five backups for safety. On my old XP system, this was true. FF takes place a new json dail

  • ReadyNAS Duo v2 impossible to access the start menu

    Hello I am new in ReadyNAS, I bought this one for a long time but only used for a few days... I try to use again, I tried to upgrade the firwmare the/admin /, but surely a bug appear, because after restart-auto, I can not access the /admin/ with my o

  • White screen with Vista

    When the computer is, I come back and the screen is completely white. A few times it becomes white at the start.

  • Possible to click on the URL in the label?

    Hello I do an application that can show the comments people have submitted - I would like to be able to allow the user to click a link in the comments and either open the browser or a webview at this link. Is this possible? I tried searching but I'm