Dynamic creation of items in the dataProvider

I am trying to find a way to display a dynamic number of objects with a datagroup and an itemrenderer. The problem is that all the examples I found do not show data running statically in the MXML tags (see the example below, in the ArrayCollection collection). Is it possible to have a picture or a vector of objects defined in actionscript that I can dynamically change and have it affect the DataGroup & ItemRenderer?




                                   <s:DataGroup itemRenderer="components.itemrenderers.myItemRenderer">
                         <s:layout>
                              <s:VerticalLayout/>
                         </s:layout>
                         <s:dataProvider>
                              <s:ArrayCollection>
                                   <local:Person firstName="Alain" lastName="Hufkens"/>
                                   <local:Person firstName="Hugh" lastName="Hefner"/>
                                   <local:Person firstName="Jimi" lastName="Hendrix"/>
                              </s:ArrayCollection>
                         </s:dataProvider>
                    </s:DataGroup>



You can assign a dataProvider in the script.

object.dataProvider = someArrayCollection;

Tags: Flex

Similar Questions

  • Call for ensureIndexIsVisible after adding items to the dataProvider

    Hello

    I have a strange behavior where call ensureIndexIsVisible does not show the correct item.

    Did I miss the correct event to listen to after adding items to the list data provider?

    Description:

    I use spark.components.List with a HorizontalLayout to display my data.

    My data is displayed using the ItemRenderer.

    After the addition of new elements to the dataProvider, I register the Event.RENDER and within this handler, I call ensureIndexIsVisible and cancel the registration to this event.

    Add some data to dataProvider - some elements of thousnd

    list.dataProvider.add (...)

    list.addEventListener (Event.RENDER,

    function renderHandler(e:Event):void

    {

    show index

    list.ensureIndexIsVisible (indexToShow);

    list.removeEventListener (Event.RENDER, renderHandler);

    });

    I made the debug:

    1. If I comment removeEventListener, it will eventually work after some time the event fires.

    2. the original location that I see is a few points behind so if I scroll a bit I can find the desired article

    Thank you

    Roy.

    This blog can be useful: http://flexponential.com/2011/02/13/scrolling-to-the-bottom-of-a-spark-list/

  • Dynamic creation of components on the page giving problems

    Hello

    We create a number of custom components to interface dynamic user on the page, according to the information, we know that when running (for some reason, we could simply not create them statically and hide and show them dynamically: Please don't suggest that you do this at the moment).

    Custom components are derived from elements of the ADF, so, for example:
    public class MyRichInputText extends RichInputText implements Serializable {
    }
    They are created dynamically in a bean that is associated with a button and used for the first time. In other words, once wle browse page, for example via tabs, or fragments, still get us an exception "Session timeout". Here is the log of the server:

    < error > < org.apache.myfaces.trinidadinternal.application.StateManagerImpl > < BEA-000000 >
    java.lang.InstantiationException: mycompany.lib.MyRichInputText
    at java.lang.Class.newInstance0(Class.java:340)
    ...
    < WARNING > < oracle.adfinternal.view.faces.lifecycle.LifecycleImpl > < BEA-000000 > * < ADF_FACES - 60098:Faces life cycle receives exceptions that are unhandled in phase RENDER_RESPONSE 6 *.
    java.lang.NullPointerException
    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._renderResponse(LifecycleImpl.java:978)
    ...
    javax.faces.application.ViewExpiredException: viewId: / myPage - ADF_FACES-30107: the page view state has expired.  Reload the page.

    In addition, just for your knowledge, we use javax.faces.STATE_SAVING_METHOD = "customer" in the web.xml file. Note that MyRichInputText is already Serializable.

    You have a solution?

    Yes.

    Have you read http://docs.oracle.com/cd/E21764_01/web.1111/b31973/ad_custom.htm

    John

  • LineChart with empty items in the dataprovider

    I get data for my dataprovider every second element empty. On the chart, it looks like "0". Can I present it as breaking graphic or graphic consists of points?

    I think what you want is to set the property to "interpolateValues" to false. This is the default value, however, so I think that you represent the values in your provider of data such as '0 '. Instead, try to set the 0 to null values. The following example shows you what I mean:



    http://www.Adobe.com/2006/mxml">
      Import mx.collections.ArrayCollection;
    [Bindable]
    public var fresh: ArrayCollection = new ArrayCollection([) collection
    {Month: "Jan", result: 2000, expenses: 1500, amount: 450},
    {Month: "Feb", result: 1800, expenses: 1100, amount: 400},
    {Month: "Mar", result: null, fresh: null, amount: null},
    {Month: "ARP", result: 1500, expenses: 500, amount: 300},
    {Month: "Peut", result: 1200, cost: 600, amount: 700}
    ]);
    ]]>

     
        
    dataProvider = "{cost} '.
    showDataTips = "true".
    >
           
               <>
    dataProvider = "{cost} '.
    categoryField = 'months '.
    />
           

           
              
    yField = "Profit".
    displayName = "Profit".
    />
               <>
    yField = "expenses".
    displayName = "expenses".
    />
           

        
        
     

    BTW, the following also works for the "Mar": data object

    {Month: "Mar"},

    But the following won't work, because the chart interprets 0 as a valid value and not the type to be ignored:

    {Month: "Mar", result: 0, fees: 0 amount: 0},

    HTH,

    Matt Horn

    Flex docs

  • How to customize display in ItemRenderer according to its index in the dataProvider in Flex 4.1?

    I went through a lot of forums to get this answer, without success. I have to admit, I'm quite 'green' with Flex and my mother tongue is the French, so if I am not clear, I apologize.

    I would like to use the same ItemRenderer for all items in a list, but only for the first (index = 0) item in the dataProvider I have 1 child of the non-visible ItemRenderer.

    Currently, I have something like that in the ItemRenderer:

    override public function the value of {} data(value:Object):void

    var itemList:List = owner as list;

    var listProvider:ArrayCollection = itemList.dataProvider as ArrayCollection collection;

    var isFirstItem:Boolean = false;

    If (listProvider.GetItemIndex (Data) == 0) {}

    isFirstItem = true;

    }

    }

    And then if isFirstItem = true, I hide the child I wanted to hide for the first item in the data provider.

    The problem is that listProvider.getItemIndex (data) == 0 seems to be true not only to article 1 in the dataProvider. The child I want to hide becomes too hidden on some (not all).

    It seems to be linked to the fact that the list has a scroller and so not all items in the list are shown at the same time.

    Does anyone have an idea how I could do this? Or just some advice, I'm really out of the solutions here.

    Thank you!

    do you explicitly say if the first element then hide the child, see the thing of the child

    itemrenderers are reused, so if you do not have the else clause so when you scroll the rendering engine is displayed in its original state

    (I guess)

  • Hi friends this is the code for the dynamic creation of user in plsql, but these statements are not run if pls help for this error

    DECLARE

    n NUMBER.

    BEGIN

    n: = 1;

    WHILE (n < = 10)

    LOOP

    CREATE a user EM | IDENTIFIED BY KLU n;

    SESSION CREATION GRANT, GRANT ANY PRIVILEGE TO EM. n;

    COMMIT;

    n: = n + 1;

    END LOOP;

    END;

    Hello

    Here is the dynamic creation of user query and giving grants to the user,.

    DECLARE

    n NUMBER.

    cr_user VARCHAR2 (300);

    gr_user VARCHAR2 (300);

    BEGIN

    n: = 1;

    While (n<=>

    LOOP

    cr_user: = 'CREATE user EM | n | "IDENTIFIED BY KLU";

    gr_user: = "GRANT CREATE SESSION, GRANT ANY PRIVILEGE to EM '. n | '';

    EXECUTE IMMEDIATE cr_user;

    EXECUTE IMMEDIATE gr_user;

    n: = n + 1;

    END LOOP;

    END;

    Edited: Removed when OTHER exceptions to Code.

    See you soon!

  • How to identify items on the checklist 'Exceptions' in the firewall of Windows XP?

    I have 40 points listed on the 'Exceptions' list Windows XP firewall. Of those, there are 24 which can be easily identified as being for use with software installed and utility.  I have 14 items listed with a term somewhat vague, called 'Services '.  I checked the lists of these TCP ports on the internet and I found that 5 are called or classified as 'no '.  Others have names that do not match what I have installed on my computer. such as dynamic and/or Private Party, Synapse non HTTPS, NUTS Bootp Server instantiates zero - control messaging, CosmoCall Universe Communications Port 2, ATI Sharp logical engine, System DVT and SecureSight Event Logging Server Port.  The others are DCOM (135), UPnP infrastructure and they are often referred to a being obsolete, according to various sources online.
    It should be our responsibility as users of computers and/or administrators to use measures to protect our operating systems using programs antivirus and antispyware up-to-date and ensuring that our systems and other operating software are updated regularly.  Thing that many of us can forget how our firewall settings are configured, including which are checked on our firewall lists 'Exceptions '.  Sometimes, you may need to remove a list control item because the software to which it applies is no longer installed or when a reliable source online checks as a checklist item is obsolete and can be deleted safely.  Unfortunately, it is not enough on line information to correctly identify some of these Firewall Exceptions as course, still being in service and for the legitimate transfer information.  There are several Exceptions to the Services on my computer that will eventually be rechecked when Windows is restarted by two programs (svchost.exe and another that I have not yet identified). How do we identify each function as legitimate?
    We have a lot to deal with when we protect our information.  Spyware, virus, worms, Root Kits and even our own programs and settings can affect the safety of our computers.  He arrived at a point where we have to develop software better which will keep a record of each file is added, changed or removed from our operating systems, while they are carefully parsed for signs to be used as a form of Malware. Using antivirus and antispyware programs, alone may not be enough protection. Our firewall settings are equally important.  We can not simply block all exceptions in the firewall, because we need to have ports open for software, monitoring of maintenance programs, email and security programs.  The big problem is to identify who is who and what they are supposed to do when they are vaguely defined as 'Services' how to determine who is who, and that one can be deleted safely?

    Well,.

    If I were in your shoes, I wouldn't have kept all programs except the default (not same remote connection or sharing as I don't use them). For others he added as exceptions, I would have checked them on: Microsoft.com and msdn.microsoft.com. If the programs are associated with MS, you will always get an answer. If there is no answer or if I'm in doubt, I have it deletes from the list of exceptions.
    Finally, if any program is affected by this and creates the connection problem, I would have added it to the exceptions. Other, I would allow in Exceptions.
    THE RULE IS TO REFUSE ANY PROGRAM THAT YOU DO NOT KNOW, AND IF YOU HAVE ANY DOUBTS. IF YOU EXPERIENCE ANY PROGRAM, CREATE PROBLEMS, YOU CAN ALWAYS ADD IT LATER.
    --
    Best regards
    DreamsCentral
    Twitter: @DreamsCentral
    LinkedIN: Linkedin.com/in/DreamsCentral
    Signed: Sunday 14 March, 2010, 14:46:38 IST
  • Remove the item from the selector

    Hey guys,.

    I am currently working on an application where I need to have a function that allows you to remove items from a selector.

    I have a table that contains all the elements. And create similar to this example code selector: link

    This is my basic approach code (does not work):

    private function removeSubject(subject:String):void {
        var newArrSubjects:Array = [];
        for(var i:int=0; i
    

    My problem is that I don't know how to really the test of equality or how to get the content of the "label".

    I have a function to add an item in the selector to work like this:

    private function addSubject(subject:String):void {
        arrSubjects.push({label: subject});
        subjectPicker.dataProvider = createDataProviderSubject();       }
    

    The createDataProviderSubject() uses the arrSubjects as their Source to create the DataProvider.

    Would be very happy if someone had a great idea to help out me

    Hey,.

    try running the following code instead and see what you get:

    private function removeSubject(subject:String):void{
    
        for(var i:int=0; i < arrSubjects.length; i++)    {        if(arrSubjects[i].label == subject)        {            /**             * use the splice method of the array             * to delete the object based on the index             *              */            newArrSubjects.splice(i,1);
    
                /** if there is a match break out of for loop */            break;        }    }
    
        subjectPicker.dataProvider = createDataProviderSubject();}
    

    This time, we are using the same table and simply removing the item u want. hope that things cleared up. Good luck!

  • Adding items to the QNX list without scrolling

    Is it possible to update the items in a list of qnx without scrolling of the list in article 1?

    I have a list of qnx that retrieves its list items in a stream, and if the list item has been scrolled, beyond every time that I update the dataprovider, it automatically reloads the list with 1 point on the screen.

    HM sounds quite interesting. what I would do is to find something to defines a set of data apart from others and makes every single tweet. There is probably an ID of the API or something. then id have a separate table, keep track of all the IDS in your current list. from there whenever u 'referesh' you can check if you got the identifiers in the new list differ from your current table of ID. If they are separately add each individual tweet of the new incoming list using the addItem() method instead of reset your entire dataprovider. hope that helps some. Good luck!

  • APEX 4.0 IE8 - definition of value with dynamic Action - no display of the result

    Hello

    I use APEX 4.0 and IE8. I made a dynamic action that fires on the editing an item.

    Event: change

    Rype of selection items

    Article: P77_item_1

    Condition: No strings attached

    Real Actions: The value

    Action: Set

    Set type: PL/SQL function body

    : P77_item_2: = Y;

    Page items to submit P77_item_1

    Items affected

    Items of Type selection

    Elements P77_item_2

    I see that it works in session. Now, I see that P77_item_2 is inserted. But there is no display of the value.

    I tried item_2 as textfield, view only, or read-only, but the behavior is always the same. What can I do to show the change in the order of the day?

    Thank you!

    Le_di wrote:

    I use APEX 4.0 and IE8. I made a dynamic action that fires on the editing an item.

    Event: change

    Rype of selection items

    Article: P77_item_1

    Condition: No strings attached

    Real Actions: The value

    Action: Set

    Set type: PL/SQL function body

    : P77_item_2: = Y;

    Page items to submit P77_item_1

    Items affected

    Items of Type selection

    Elements P77_item_2

    I see that it works in session. Now, I see that P77_item_2 is inserted. But there is no display of the value.

    I tried item_2 as textfield, view only, or read-only, but the behavior is always the same. What can I do to show the change in the order of the day?

    Do not have access to an instance of APEX 4.0 to study, but any code of "PL/SQL function body" must include a RETURN clause:

    :p77_item_2 := 'Y';
    return :p77_item_2;
    
  • any button in the dynamic region you put me the default taskflow

    Hi all

    I used Oracle Adf 12 c,

    I do application with a jsf page and using Panel springboard and inside he ShowDetailItem inside static area Dynmiac area inside.

    Jsf Page > > Panel Spring Board > > view item details > > static region > > dynamic region

    the problem is when I click on the button in the dynamic region it navigate to the default taskflow.

    My problem is solved by changing the scope of the managed bean (application scope in sight).

  • Tabluar form hide/show items on the loading of the page

    Hi all

    Apex 4.1

    I use JS to display or hide fields, based on the values of other fields, cela in a tabular presentation. So it is used as a work-around as dynamic actions are not able to do out of the box on tabular forms (that I know of).
    The code I use is something like this:

    In the page header:

    function test (pThis) {}
    get the index of line curren on changes
    var currIndex = $('select[name="'+pThis.name+'"]').index ($x (pThis.id));
    If (pThis.value < 0) {}
    . style.display $('input[name="f06"]') [currIndex] = 'block ';
    }
    else {}
    . style.display $('input[name="f06"]') [currIndex] = 'none ';
    }
    }

    In the attributes of the item in the column 'source '.
    OnChange = "JavaScript:test (this); »

    This fires that when the source column is changed, but not working when you load at the start page when it is filled with already stored reports. So it works only when a field is changed to the hand.

    How can I force this action shot the loading of the page so the rule (hide fields) also gets applied to existing records?

    Concerning
    Bottom

    Down de Klerk wrote:
    Hi all

    Thanks for the comments.
    So far I m unable to make it work. Fire code (debug using alert messages, and these show upwards), but the suggested procedure does not work.

    I tried all kinds of entry points, as for example the test via dynamic when a button is clicked, tried action on loading the page, and also via the $(document) .ready (function
    The function is executed and nothing happends, no error does not code so should be ok.
    I'll investigate further and let you know what happends. Don't know if the class type of the associated field f06 might have something to do with it, but one is LOV/Select list type

    This code is looking for input i.e. text, checkbox etc and will not find a slelect list.

    You must change the jquery like this selector

     $(document).ready(function () {
          jQuery.each($('select[name="f06"]'), function () {
               hide_field(this);
          });
     alert("function executed");
     });
    
  • Any way to update all items at the same time?

    Any way to update all items at the same time?

    is one by one, the only way to update?

    I have 68 articles up to 800 MB.

    Unfortunately, the team has not added an update all feature. I think that this is scheduled for February.

    If you have your folders and files properly configured with a sidecar.xml file, consider the deletion and re-creation of the folio.

  • My ComboBox does not work if I hardcode the dataProvider, not if the dataProvider of the remote object

    I have a ComboBox where the user can select a category of products to display. The ComboBox control is sitting on a custom component and the ArrayCollection collection that fills created in the same element that displays the list.

    I have two versions of the element containing the ComboBox control.

    Version 1:

    / / Create new variable as ArrayCollection collection tuped

            [Bindable]

    private var categoryList:ArrayCollection;

    / / initData method called on creationComplete

    private function initData():void{ }

    / / set values in the ArrayCollection collection

    categoryList = new ArrayCollection([ )

                "All Categories"

                      , "Appetizers"

                , "Butchery"

                , 'Candy & chocolate'

                , "Desserts"

                , 'Fruit & jam'

                , 'Gifts'

                , 'Grill & barbecue'

                , 'Honey and syrup'

                , 'Kitchen accessories'

                , "Little daviet Childrens Fun Food"

                , 'Denounced & other oils'

                , 'Oives & olive products'

                , « Pasta »

                , "Paste & fish"

                , 'Rice and cereal'

                , 'Sauces'

                , "Seasonings and Condiments"

                , 'Spreads'

                , "Truffles and mushrooms"

                , 'Vegetables'

                , 'Vinegar'

                ]);

    / / make this collection the data provider for catCombo

    catCombo.dataProvider = categoryList.

            }

    Version 2 (the result of a call to a ColdFusion cfc):

    / / Create new variable as ArrayCollection collection tuped

            [Bindable]

    private var categoryList:ArrayCollection;

    private function categoryListHandler(event:ResultEvent):void{ }

    categoryList = event.result as ArrayCollection; collection

    var catObj:Object = new Object();

    catObj.merchantCategory = 'all categories'

    categoryList.addItemAt (catObj, 0);

    catCombo.dataProvider = categoryList.

            }

    Everything else is identical in both versions of the custom component. The ComboBox is created like this:

    " < mx:ComboBox id ="catCombo"rowCount ="16"" "

          styleName = " " glass "

    Exchange = "dispatchFilter (); »

    " labelField ="merchantCategory"" "

          / >

    In both cases, catCombo is filled correctly. But...

    In version 1, when I select a different category, everything works as expected.

    In version 2, when I change the category, said filter "0 selected items" and nothing appears, even if I go back to "all categories". It's as if the filter sees nothing once there is a change in the selection of catCombo.

    Of course, I would prefer Version 2 because the catalog - and its categories - change in the month.

    So gurus, I would really like to start the new year with Version 2 of work, any ideas would be great appreciated. Everyone in the mood?

    Happy new year

    Carlos

    This code populates the combo very well box.

    I do not use a VO, or CFusion if... the thing with VO, I think it is we can do a selectedItem live on it because it is as [object], [object] you need actually to extrapolate this information or make it. toString();

    You have drawn to see what is selected when you select an item in the drop-down list? is this [object], [object]...

    I guess the cheapo to do would be to only capture the drop-down list box in a variable.

    So have the right filter for the variable that will be given, rather than the filter directly from the drop-down list box?

    It is quite difficult to the bug with all the code enough before you, but when you are only provided only a snippet of the code it makes it even harder.

  • Restrict the dataProvider of drop-down list box to display a field.

    Hello

    I wonder if there is a way to use an ArrayCollection collection as the dataProvider for a ComboBox but only allows him to display a field as you can do with a DataGrid control by using the dataField on the column definition property.

    So, let's say I have a collection of letters and numbers ArrayCollection, and I want the ComboBox control to display only the letters.  Is it possible to specify this?

    Thank you!

    Use the labelField property to specify the field of ComboBox dataProvider to display in the ComboBox control.

    This means that you have the items in the collection ArrayCollection which are objects or XML, etc.

    If this post answers your question or assistance, please mark it as such.

Maybe you are looking for