Bind Dictionary to dataProvider

I have a class which stores data in a dictionary such as:
[Bindable]
public var data:Dictionary;
Person bill = new Person("bill");
data["bill"] = bill;
Ok, I have a DataGrid which I would like to bind to this
dictionary's values (i.e. the Person objects). I realize that the
"dataProvider" for a DataGrid can only be an ArrayCollection so is
there a nice way to get the dictionary values into an
ArrayCollection?
Or do I have to maintain a separate ArrayCollection just to
let the view bind to it?

If I needed to bind data to a dictionary , and have the data referenced in a collection I would do this.  This way , when you modify the dictionary , the datagrid will receive the updates.
public var dictionary:Object = {};
public function addPerson( person:Person ):void
   dictionary[person.id/name/identifier] = person;
   dispatchEvent(new Event("peopleChange"));
[Bindable(Event="peopleChange")]
public function get peopleCollection():ArrayCollection
  var collection:ArrayCollection = new ArrayCollection();
for( keys in the dictionary )  //Not actual Flex code , I forget how to loop over the keys of a hashmap
   collection.addItem( dictionary[key] );  // We are adding people to the collection
return collection;
<List/DataGrid dataProvider="peopleCollection" ... />

Similar Messages

  • Issue on binding e4x to dataprovider

    I have a items.xml like this:
    <items>
         <item>..</item>
         <item>..</item>
         <item>..</item>
    </items>
    In mxml, the codes are:
    <fx:XML id="dataSet" source="items.xml" format="e4x"/>
    <mx:DataGrid dataProvider="{dataSet.item}">
    The datagrid is empty.
    Anyone can help?  thanks!

    Thanks!
    I binded it with Datagrid, and I must set the dataFields in  DataGridColumn,
    not like normal XML( Object, not e4x) which don't need to set those
    datafields.

  • Binding dictionary to RibbonGalleryCategory

    Hi,
    I am binding a ribbon combo box item source using a dictionary. The binding is working fine but when I open the drop down and press the down arrow, the dictionary is showing up in the combo box.  Below is my code and screen shot of the problem.
    <ribbon:RibbonComboBox Label="Show:">
    <ribbon:RibbonGallery SelectedValuePath="Key"
    SelectedValue="{Binding DropDownSelectedValue}">
    <ribbon:RibbonGalleryCategory ItemsSource="{Binding DropDownItemsDictionary}"
    DisplayMemberPath="Value"/>
    </ribbon:RibbonGallery>
    </ribbon:RibbonComboBox>
    Regards,
    Ramakrishna
    Ramakrishna

    Hi Ramakrishna,
    >>The binding is working fine but when I open the drop down and press the down arrow, the dictionary is showing up in the combo box
    I'm not sure what the issue you faced is, do you mean the red border outside the dropdown list?
    If this is your issue, please check the type of DropDownSelectedValue property, it should be the same as the type of Dictionary's Key.
    For example, for this dic: Dictionary<int, string>, DropDownSelectedValue property should be
    int type.
    Here is my completed sample:
    <DockPanel>
    <ribbon:Ribbon DockPanel.Dock="Top" Title="Ribbon">
    <ribbon:RibbonTab Header="Tab1">
    <ribbon:RibbonGroup Header="Test" >
    <Grid>
    <StackPanel Orientation="Vertical">
    <ribbon:RibbonComboBox Label="Show:">
    <ribbon:RibbonGallery SelectedValuePath="Key" SelectedValue="{Binding DropDownSelectedValue}">
    <ribbon:RibbonGalleryCategory ItemsSource="{Binding DropDownItemsDictionary}"
    DisplayMemberPath="Value"/>
    </ribbon:RibbonGallery>
    </ribbon:RibbonComboBox>
    <Label Content="SelectedValue:" />
    <TextBlock Text="{Binding DropDownSelectedValue}" />
    </StackPanel>
    </Grid>
    </ribbon:RibbonGroup>
    </ribbon:RibbonTab>
    </ribbon:Ribbon>
    </DockPanel>
    public partial class Window1 : Window, INotifyPropertyChanged
    // Declare the event
    public event PropertyChangedEventHandler PropertyChanged;
    private Dictionary<int, string> dic = new Dictionary<int, string>();
    public Dictionary<int, string> DropDownItemsDictionary
    get { return dic; }
    set { dic = value; }
    private int _DropDownSelectedValue = 0;
    public int DropDownSelectedValue
    get { return _DropDownSelectedValue; }
    set {
    _DropDownSelectedValue = value;
    // Call OnPropertyChanged whenever the property is updated
    OnPropertyChanged("DropDownSelectedValue");
    // Create the OnPropertyChanged method to raise the event
    protected void OnPropertyChanged(string name)
    PropertyChangedEventHandler handler = PropertyChanged;
    if (handler != null)
    handler(this, new PropertyChangedEventArgs(name));
    public Window1()
    InitializeComponent();
    dic.Add(1, "all");
    dic.Add(2, "new");
    dic.Add(3, "old");
    dic.Add(4, "recent");
    this.DataContext = this;
    Screenshot:
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Binding feature to dataprovider

    i make my own dataprovider component. can i add properties to this component that has valuebinding feature? i can add value binding featured properties to the visible classes that inherited UIComponent.
    i use rave metadata generators.

    If you add valuebinding properties and then you may have to provide your own value expression resolvers. Have you looked at the basic component source code comes with Creator at <craetor-install>rave2.0/docs
    - Winston
    http://blogs.sun.com/winston

  • Getting problem in binding DropDown List with table data in visual JSF

    Hi All,
    I am new to visual JSF.
    I am getting few problems while working over components.
    I have succeeded in binding data of Person table in a drop down list .
    By just drag drop ..it worked.
    But while connecting to external DB this drag drop mechanism didn't work for me .
    1st problem that i faced was by dragging method columns are not visible when i did right click-> bind to Data -> DataProvider window .
    But i am successfully printed table Data in backend ie: by putting
    for(int i=0; i<xn_white_listDataProvider.getAllRows().length;i++){
           System.out.println("  value :"+xn_white_listDataProvider.getValue("SUB_ID",xn_white_listDataProvider.getRowKey(Integer.toString(i))));
    }I am not getting how to set Items in dropdown1
    I tried putting
    HelloSh.xn_white_listDataProvider.options['XNODE.XN_WHITE_LIST.SUB_ID, XNODE.XN_WHITE_LIST.SUB_ID'but it didn't work while for person data table
      items="#{HelloSh.personDataProvider.options['PERSON.PERSONID,PERSON.NAME']}"it is working
    when i am writting items="24,28" in dropdown1 box
    & printing its value in static text Like
    <webuijsf:staticText id="staticText3" style="position: absolute; left: 72px; top: 120px" text="#{HelloSh.dropDown1.items}"/> it is printing fine .
    Plz help me in this regard.
    Any clarification if needed plz let me know.
    Thanks in advance.

    <h:selectOneMenu id="menu1" styleClass="selectOneMenu">
    <f:selectItems value="*#{selectitems.pc_DynamicPortletEdit.regList}*" />
    </h:selectOneMenu>When we bind the list to the h:selectOneMenu the code in the JSP will be as given above.
    My doubts here are
    1) But when i tried to bind the list to a selectonemenu the code in the JSP is looking like this one
    <h:selectOneMenu id="menu1" styleClass="selectOneMenu">
    <f:selectItems value="*#{selectitems.pc_DynamicPortletEdit.regList.regList.toArray}*" />
    </h:selectOneMenu>2) Also in the runtime instead of displaying the values in the dropdown, i am getting the object names (javax.faces.model.SelectItem@680d0ccc) in the drop down.
    What am I doing wrong? Any help here would be usefull for me.
    BTW,
    the code in the backing bean for setting the values is like this
    List dropListValue = new ArrayList();
        for (int x=0; x<result.length; x++){ //where result is array of string values              
            SelectItem tempSelect = new SelectItem();
            tempSelect.setLabel(result[x]);
            tempSelect.setValue(result[x]);
            dropListValue.add(result[x]);                      
    this.setRegList(dropListValue );The bean is in request scope only.

  • Updating dataprovider causes mess when scrolling in AdvancedDataGrid

    Hi
    I have a problem using AdvancedDataGrid :
    I bind the ADG dataprovider to a XML in my model, like this :
           <mx:AdvancedDataGrid
                <mx:dataProvider>
                    <mx:HierarchicalCollectionView filterFunction="{model.filterFunction}" source="{hierarchicalData}"/>
                </mx:dataProvider>
                <mx:columns>   
                    <mx:AdvancedDataGridColumn labelFunction="{model.menuLabel}"/>
                 </mx:columns>
           </mx:AdvancedDataGrid>
        <fx:Declarations>
            <mx:HierarchicalData id="hierarchicalData" source="{model.myXML.xmlNode}"/>
        </fx:Declarations>
    When I start the application, the ADG displays poperly my model.
    Then I programmaticaly add a node to myXML in my model, the ADG renders it and adds a row. So far so good.
    Then when I scroll vertically in the ADG, some rows are added or removed, or the mouse highlighting jump to another line... Total mess.
    I read that this may be because ADG recycle renderers and so we have to override the "set data" function in renderer. But here I don't use renderer but labelFunction.
    And I don't have the problem when scrolling, until I change the dataprovider.
    Do you have an idea ?

    can you post your source project? you must be addding the node the array collec
    tion more then once??? maybe. I wouldnt be able to tell unless you posted your project and we can take a look at it.
    Miguel

  • Bind a data on a Tab set component

    Hello all people!
    Sorry for my dirty English!
    I've created a little intranet and would use a tab set component for a view of the data in mysql datasource!
    But if I put in the tab set the Property Sheet component and bind it to dataProvider, the init() of the java file not run!
    Can I use the propety sheet with tab set?
    If the response is "YES"; Why this don't work?
    Also I did use a page fragment for any tab?
    thank's a lot!

    I need more info. A property sheet is a container just like group or grid but its structured into layers: Property Sheet, then Property Sheet section, and then Property.
    Property's are ment to contain one or more components. There is a bug that you cannot drag/drop a component right on a property, you have to use the outline window to get them there).
    What exactly did you bind to in the property sheet component? Which part? What other fields are on the tabs?
    Please add a MessageGroup component to the page and re-run to see if you get any errors that may help..
    Thanks,
    Lark

  • How to use one Filter Pane to multiple Dataproviders

    Hi Experts.
    i have checked the threads on this but i did not get correct solution.
    we have issue in using single Filter pane web item in WAD for three different dataproviders ( three dataproviders have same free charecteristics and variable) charecteristics in row and keyfigures are different.
    thanks in advance.
    Regards
    Raj.

    Hi Gill,
    Thanks for your Quick responce.
    when we use the single filter pane, filter conditions are working for only first dataprovider (since data binding is to dataprovider 1. in affterted dataproviders i selected dataprovider 2 and 3, but filter pane is not active for other two dataproviders in tabs.
    thanks in advance.
    Any inputs please....
    Regards,
    Raj.
    Edited by: Rajsapbi on Apr 6, 2009 9:22 AM

  • Dynamic Selection in WAD.

    Hi,
    I have 3 Queries, each has same variable name (Calendar Date). Also I created 3 views with same selection as input.
    Now Created one WAD and assigned these 3 views in different cells. In WAD property I have disabled the variable screen display option. Now when I execute the WAD, by default it is getting execute with the selection which I have given while creating views.
    My requirement is to place the drop down box at the top of WAD and assigned the calendar date variable to that. Also instead of taking the selection value from view, it should dynamically run for last 7 days. Is there any functionality to achieve this?
    Regards,
    Jackie.

    Hi.
    Fist add TEXT webitem above your chart.
    Goto databinding in webitem properties, seelct "simple text" and write your text (lets asy "Report for period").
    Then after TEXT webitem add INFO_FIELD webitem.
    In "internal display" in properties set ONLY_VALUES = ON (it will remove the name of variable before value of variable).
    In data binding set your dataprovider adn in "list of text elements to display" select "variable value" and select your variable.
    Regards.

  • Oracle jdbc driver problems in netbeans 5.5

    need help again....i'm experience a problem. the problems are :
    i connect from netbeans 5.5 to oracle database express client 10g using jdbc driver ojdbc14.jar. the connection succeded (all the tables appears and i even can view the data). but when i trying to bind data to a drop down list component (with right click to the dropdown list component and then bind data), the dataprovider of that table appear in red color and there's no field appears in that. i'm so confused? i already add the ojdbc14.jar driver to the following path :
    1. i create a new class library in netbeans with consist of that driver,
    then added to my project (right click in my project then add library).
    2. then i added the ojdbc14.jar driver to my tomcats lib at "C:\Program
    Files\netbeans-5.5\enterprise3\apache-tomcat-5.5.17\common\lib".
    Is there any additional settings in using oracle jdbc driver? Does anyone knows? thanks a lot for the answers...
    Message was edited by:
    darma_sadha

    Hi!
    I'm using NetBeans 6.5 and I'm having some troubles to connect.
    The steps I've made:
    - Create the connection pool in Glassfish, nothing special, just standard parameters (Based on javax.sql.DataSource and including URL, Username and Password).
    - Create the JDBC resource associated with that connection pool,let's say jdbc/test.
    Now in NetBeans I register the driver:
    - New driver -> Find the ojdbc14.jar and from the options that I can choose it shows: oracle.jdbc.OracleDriver and oracle.jdbc.driver.OracleDriver.
    If i choose without +.driver+ I got the thin drivers (the ones i want) and if i chosse the one with the other one I got the OCI drivers. So I choose the first option oracle.jdbc.OracleDriver
    - Then I go to my project and click New -> Entity Classes from Database and from Datasource I select jdbc/test and it shows the following error message:
    Unable to find the driver oracle.jdbc.driver.OracleDriver. Please register this driver in the Databases.
    I can fix it if while registering the ojdbc14.jar I select the second option (*oracle.jdbc.driver.OracleDriver*) but with this option I need to specity the connection to use OCI instead of the desired thin driver.
    I hope you'll understand and help me somehow
    Edited by: KILE on Oct 10, 2008 2:26 AM

  • Populating a ComboBox from DB query

    Hello –
    I have created a ComboBox to allow users to choose a category
    as a filter for a products catalog. The list of categories is
    returned by one of the functions of a ColdFusion CFC I’m
    using in the app; it has been tested and examined in the debugger
    and is returning the correct ArrayCollection.
    For now, I have ended up hard coding the ArrayCollection that
    populates the ComboBox, like this:
    <mx:ComboBox id="series" styleName="glass" width="250"
    rowCount="16"
    change="someFunction();">
    <mx:dataProvider>
    <mx:ArrayCollection>
    <mx:Object label="All Categories" data="0"/>
    <mx:Object label="Interlocking Puzzles" data="1"/>
    <mx:Object label="Math Games" data="2"/>
    // etc. - 16 categories
    </mx:ArrayCollection>
    </mx:dataProvider>
    </mx:ComboBox>
    Of course, the above works fine, but I would prefer to use
    the CFC. I tried something like:
    <mx:ArrayCollection id="categList"
    source="mx.utils.ArrayUtil.toArray(roService.roMethod.result);"
    <mx:ComboBox dataProvider="{categList}" />,
    but I don’t know how to tell the component what the
    ‘label’ is and what the ‘data’ is . I am
    sure this is an easy one for someone with a little experience.
    Please, somebody, give me an idea how to code this, or at least
    where I can look it up. I have read the whole help material, but
    can’t figure it out.
    Regards,
    Carlos

    For top-level properties of your item objects (which I think
    you will have), just specify the labelField. For values in nested
    objects, or for calculated or concatenated columns, you wil need to
    use a labelFunction.
    I advise against binding directly to the result
    ("lastResult", to be specific when binding) and advise using a
    result handler function in which you can inspect the exact
    structure of the event.result object (just "result" in an event
    handler).
    To work up to this, why not hard code a bit of dataProvider
    that is EXACTLY what you think you will be getting from the CFC.
    Put it in a [Bindable] variable and bind the combobox dataProvider
    to that. Use labelField or labelFunction to get the combobox to
    work with that, then implement the data service call, and in its
    result handler, assign the event.result to the bindable variable.
    Voila!
    Tracy

  • Populating a poplist in a query

    I am populating a poplist at runtime (from another master table) depending on the selected value in a field before that. From the populated description I get the code and keep insert this to the based table which is used to insert the entered data.
    When doing a query for the inserted record i need to get the above saved code and populate the description to the same poplist.
    Is there an easy way?
    Message was edited by:
    user483578

    For top-level properties of your item objects (which I think
    you will have), just specify the labelField. For values in nested
    objects, or for calculated or concatenated columns, you wil need to
    use a labelFunction.
    I advise against binding directly to the result
    ("lastResult", to be specific when binding) and advise using a
    result handler function in which you can inspect the exact
    structure of the event.result object (just "result" in an event
    handler).
    To work up to this, why not hard code a bit of dataProvider
    that is EXACTLY what you think you will be getting from the CFC.
    Put it in a [Bindable] variable and bind the combobox dataProvider
    to that. Use labelField or labelFunction to get the combobox to
    work with that, then implement the data service call, and in its
    result handler, assign the event.result to the bindable variable.
    Voila!
    Tracy

  • uix:table using JSP tags

    I cannot figure out how to bind a dataobject list using the <uix:table> tag. Could someone please help me with this.
    Jeff Driskell

    Do you mean that you already have a DataObjectList which you want to set as the <uix:table>'s tableData attribute? If so, I believe you have two choices:
    1. You can use a scriptable variable for the table and call setTableData() explicitly on the TableBean.
    2. You can use a scriptable variable for a dataScope and register a DataProvider which provides access to your DataObjectList. Then, you can use the tableDataBinding attribute of the <uix:table> tag to bind to your DataProvider.
    Examples of both of these techniques are provided in the "Scriptable variables" section of the "UIX JSP Tag Libraries" section of the UIX Developer's Guide.

  • How to use CheckBox in Table to do mulit-selection in Creator2 Update1?

    Hi.
    I put CheckBox(checkbox1) into Table to do a multi-selection effect..
    and I set checkbox1's selected to true to make default selection.
    however checkbox1 doesn't show selected in at Design Time in Creator2 , and also at Runtime in Firefox.
    then I put another CheckBox(checkbox2) outside the Table, and set selected to ture.
    chekcbox2 is default selected both in Designtime and Runtime.
    I am confused about that
    And, more troubles is, I can't know which Row datas were checked.
    I call CheckBox.getSelected(checkbox1.getID()) got NULL.
    I call checkbox1.getSelected() got NULL.
    Then I write a TableDataProvider to handle this Table and always return Boolean.TRUE at selection field
    But still no work.
    Does anyone know how to do multi-selection in Table?
    Thanks a lot.

    Hi,
    I also test RadioBox in Table and set RadioBox named 'rbSelection' , the table is bind to a dataprovider.
    But, It does't work, too.
    I can't get the selection from any API I know in a Button action (outside of Table)
    RadioButton.getSelected(rbSelection.getName())) return null
    rbSelection.getSelectedValue() return true
    rbSelection.getSelected()) return null
    rbSelection.getSubmittedValue()) return null
    tableRowGroup1.getSelectedRowKeys().length size is 0
    But when I use ((HttpServletRequest)this.getFacesContext().getExternalContext().getRequest()).getParameter("rbSelection")
    I can get the correct selection result.
    Is this a Creator2 bug or my mistake?
    THANKS~

  • Flex DataGrid Component

    Can i extend the Flex DataGrid using ActionScript and create as  Add-On Component ?

    I've been trying to get this to work.  But i'm having issues   Not sure if it's related to the Array binding limitation mentioned in the release notes.  Maybe someone else has some ideas.
    I'm trying to bind to the dataProvider property of the DataGrid.  That way when the user in Xcelsius selects a range, it will bind the data in the excel sheet to the DataGrid.
    Problem is that i'm only getting one value to update (specifically the top value).  At this time i'm only trying to bind a single column of data.
    I noted that the commitProperties function gets called whenever a cell changes that i'm bound to, but the dataProvider is only receiving the first value of the array.  Even odder is that the ArrayCollection that i receive simply looks like this:
    commitProp:dataProvider=(mx.collections::ArrayCollection)#0
      filterFunction = (null)
      length = 1
      list = (mx.collections::ArrayList)#1
        length = 1
        source = (Array)#2
          [0] 1
        uid = "A37C62CC-F3DC-E1B1-8159-CE984C2CCE33"
      sort = (null)
      source = (Array)#2
    So i see that i get an array collection of ArrayList objects, the first one of which simple contains the value in the excell sheet "1".
    I noted that the proxy.bind function has a parameter called "chain", maybe this is what i need to get multiple value binding?  The documentation for the calls are pretty basic, which is understandable as this is new technology.
    So anyone have some ideas?  Maybe someone from BO who is apart of the SDK group can comment?

Maybe you are looking for

  • A600 setup with Verizon TV

    I wanted to start this subject to see if any end users have gone from Direct TV to Verizon Cable TV successfully. I had a customer that was sold the Motorola QIP2500-3 Set Top Terminal. After going through Windows media center setup the customer was

  • Word to PDF does not keep hyperlinks in Table of Contents ?

    I have used my free trial of Adobe CreatePDF before purchasing the annual subscription. I was surprised to see that the PDF document did not keep the clickable hyperlinks that Word uses in a Table of Contents. As this is the exact same behaviour as t

  • Adding Delete Icon in Report with Notification msg

    Hi Friends, I want to display Delete icon in every row of report.So i followed the below link and i implemented.But i want to display the Confirmation Notification to the user *(eg.Are You sure want to delete this record?)* Before deleting the partic

  • Can anyone help to REMOVE iOS4.0 from my Iphone3G? I want my old 3.1.3!!!

    DO NOT upgrade to the 4.0 for your 3G or 3GS phone if you already haven't! My phone has been completely screwed up since I did for my 3G! I did the full restore, and it's still HORRIBLE! Any application now takes 3-4 seconds to open. Applications eit

  • Large UGA in a Dedicated connections DB

    Hi all, I obtained the total PGA and UGA memory used by current sessions from the query below. All the connections used Dedicated connections. My question is: Why the UGA is that large (close to total PGA)? Is that normal for a database that doesn't