Iterate through the child Objects in a components

I have a custom component named myComp that has three TextInputs. And in the main application there is a button that adds this component dynamically to the VBox named myVBox, I would like to know how to iterate through the added components and show the text inside each of the TextInputs in an Alret box. I am pretty new to flex and I couldn't find any examples for it.
Thanks,

Sample code,
Custom Component
MyComp1.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml">
     <mx:TextInput id="txt1" width="100" />
     <mx:TextInput id="txt2" width="100" />
     <mx:TextInput id="txt3" width="100" />
</mx:HBox>
Application
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
     xmlns:mx="http://www.adobe.com/2006/mxml"
     layout="absolute"
     creationComplete="init()">
     <mx:Script>
          <![CDATA[
               import mx.controls.Alert;
               import com.MyComp1;
               private function addComponent(event: MouseEvent): void {
                    var myComp1: MyComp1 = new MyComp1();
                    myVBox.addChild(myComp1);
               private function getText(event: MouseEvent): void {
                    var alertMsg: String = "";
                    for (var i: int = 0; i < myVBox.getChildren().length; i++) {
                         if (myVBox.getChildAt(i) is MyComp1) {
                              var myComp: MyComp1 = myVBox.getChildAt(i) as MyComp1;
                              alertMsg += myComp.txt1.text + "\t" +
                                             myComp.txt2.text + "\t" +
                                             myComp.txt3.text + " \n"
                    Alert.show(alertMsg);
          ]]>
     </mx:Script>
     <mx:VBox width="100%" height="100%">
          <mx:Button label="Add Comp" click="addComponent(event)" />
          <mx:Button label="Get Value" click="getText(event)" />
          <mx:VBox id="myVBox" width="100%" height="95%">
          </mx:VBox>
     </mx:VBox>
</mx:Application>
Hope this helps you

Similar Messages

  • Transfer through the iterator object....

    Hi,
    I am writing a code in JSP where i need to transfer through the iterator object and print all the objects i.e. object name and the value in the page. Please give me an example how to write the code in jsp with the iterator object.
    thanks.

    [http://www.google.com/search?hl=en&q=JSP+iterator+examples&meta=]

  • How to split a string into tokens and iterate through the tokens

    Guys,
    I want to split a string like 'Value1#Value2' using the delimiter #.
    I want the tokens to be populated in a array-like (or any other convenient structure) so that I can iterate through them in a stored procedure. (and not just print them out)
    I got a function on this link,
    http://www.orafaq.com/forum/t/11692/0/
    which returns a VARRAY. Can anybody help me how to iterate over the VARRAY, or suggest a different alternative to the split please ?
    Thanks.

    RTFM: http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/collections.htm#sthref1146
    or
    http://www.oracle-base.com/articles/8i/Collections8i.php

  • Delete only the child object and not the parent object

    Hi,
    I have the below code:-
    TAnswer
    @ManyToOne(fetch = FetchType.LAZY)
         @JoinColumn(name = "question_id", nullable = false)
    //     @Cascade(value=CascadeType.ALL)
         public TQuestion getTQuestion() {
              return this.TQuestion;
         }     TQuestion
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "TQuestion", orphanRemoval = true)
         @Cascade(value=CascadeType.ALL)
         /*@Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE,
                org.hibernate.annotations.CascadeType.DELETE,
                org.hibernate.annotations.CascadeType.MERGE,
                org.hibernate.annotations.CascadeType.PERSIST,
                org.hibernate.annotations.CascadeType.DELETE_ORPHAN})*/
         public List<TAnswer> getTAnswers() {
              return this.TAnswers;
                   In Java:-
         public void removeAnswers(TQuestion question)
                        throws ApplicationException {
                   List<TAnswer> answerList =  question.getTAnswers();
                   deleteall(answerList);
         public void deleteall(Collection objects) {
                   try {
                        getHibernateTemplate().deleteAll(objects);
                        getHibernateTemplate().flush();
                   } catch (Exception e) {
                        throw new ServerSystemException(ErrorConstants.DATA_LAYER_ERR, e);
         }               Here the "deleteall" will delete both the answer records and question records, I don't want the questions
         records to be deleted. I have tried making the question as null when we set the answer object to be passed for delete
         bit still it is     deleting the question records as well.How to achieve the above in deleting only the answer (child) records
         and not the question(parent) record? Is there any thing we need to do with @Cascade for Question object? Please clarify.
    Thanks.

    What does deleteAll do, it doesn't look like a JPA method. You might want to ask your question on your provider forum, or use straight JPA methods as a simple EntityManager.remove(answer) on each answer in the collection should work.
    Regards,
    Chris

  • Iterate through a treemap object

    how can 'iterate' through treemap object like you can with an ArrayLIst
    like:
    Iterator it = arraylist.iterator();

    Here is an example:
    TreeMap users = (TreeMap)session.getAttribute("users");
    Iterator i = users.entrySet().iterator();
    while (i.hasNext()) {
    Map.Entry e = (Map.Entry)i.next();
    if (e != null) {
    String key = (String)e.getKey();
    if (key != null && key.length() > 0) {
    String value = (String)e.getValue();
    } // end if key not null
    } // end if entry not null
    } // end while

  • How can I iterate through the TextObjects of a Report object?

    Post Author: EMoscosoCam
    CA Forum: Other
    Hello(Using Crystal Reports XI Release 2 and Visual Basic 6)I have the name of a TextObject as a string. I would like to make something like this:Dim objReport As CRAXDRT.Report' once initialized from an RPT fileobjReport.TextObjects(strName).Supress = TrueOf course, there is not such a thing as a TextObjects collection. Is there a similar way to do what I want? Consider that the TextObject's name to be supressed is a string, and that I do not have it before-hand.Thanks a lot.

    Post Author: JonathanP
    CA Forum: Other
    Hi;
    You can loop through every section, then through every object, and check to see if it is a TextObject or not.
    ie:
    Dim I As IntegerDim X As IntegerFor I = 1 To Report.Sections.Count    For X = 1 To Report.Sections.Item(I).ReportObjects.Count        If Report.Sections(I).ReportObjects.Item(X).Kind = crTextObject Then            Report.Sections(I).ReportObjects.Item(X).TextColor = vbRed        End If    Next XNext I
    Regards,
    Jonathan

  • How to fire event to generate insert message for the child objects?

    We are in process to integrate CRM On Demand and existing Microsoft SQL DB.
    We have the following problem:
    For ex., we have CRM Object_1 that already synchronized with the SQL DB. CRM also has independent Object_2 and its child Object_2.1
    We dicided that we want to connect the Object_2 as child to the Object_1.
    The question is how to fire event to generate insert message for the Object_2 and Object_2.1?
    What is the best technique? Is it possible to do it by workflow configuration or it needs to be done programmatically?
    Thanks,
    Dmitry
    Edited by: 955827 on Aug 29, 2012 11:57 AM

    Hi,
    integration events can be generated only via worklow. You will need to create separate workflows for each record type (regardless if it is child or parent) because a workflow for the parent record type will not trigger when a child record is created/ associated. Also, the association workflows will trigger only when the specific event occurs.
    There is not way to generate the integrtaion events programatically. They are generated by workflows and are read/ interpreted by a code extension.

  • Unable to access protected function from the child object

    Hi all ,
    I have an abstract class having one protected method
    package foo;
    public abstract class A {
      protected String getName(){
                 return "ABC';
    package xyz;
    public class B extends A {
              public void print(){
                              *super.getName();//this will get called*
    package abc;
    public class Ex {
            public static void main(String [] args){
               B b = new B();
               *b.getName(); //Im not able to calll this function*
    }{code}
    My question is why I m not able to call the protected method from child instance but inside the class ???
    I have checked this link , it also didn't say about the instance access or access within class .
    [http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html]
    Thanks and regards
    Anshuman
    Edited by: techie_india on Aug 31, 2009 11:25 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    jossyvjose wrote:
    Hi Winston,
    Did you mean like this? But still same behaviour.
    package abc;
    public class Ex extends A {
    public static void main(String [] args){
    B b = new B();
    b.getName(); //still i am not able to calll this function
    }No. Class 'Ex' would have to extend B in order to call b.GetName(). And I would definitely not make Ex part of your hierarchy (it's the sort of thing you see in SCJP questions, but definitely a bad idea).
    What you can do though is to override the method; and Java allows you to change the visibility of overriden methods, provided they are more open. Thus, the following would be allowed:
    package foo;
    public abstract class A {
       protected String getName(){
          return "ABC';
    package xyz;
    public class B extends A {
       public void print(){
          System.out.println(super.getName()); // your previous code does nothing...
       public String getName() { // Note the "public" accessor
          return super.getName();
    package abc;
    public class Ex {
       public static void main(String [] args){
          B b = new B();
          b.getName(); // And NOW it'll work...
    {code}Note that this is just example code. I wouldn't suggest it as general practise.
    Also, when you write *public* methods, you should generally make them *final* as well (there are exceptions, but it's a good habit to get into; like making instance variables *private* - just do it).
    HIH
    Winston                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Iterating through master view objects and child view objects in same page

    I am working on a project using ADF UIX and Business Components.
    I have an application module with two view objects one the master view object and the second the detail object. They are related via a view link.
    I would like to iterate through the master view objects displaying a customer name as bold text and then below each customer name I'd like to display the detail records in a table via the detail view object i.e. a seprate table for each customer.
    Is this possible - I haven't had much luck!?
    Thanks in advance.

    That's because
    $(".ms-vb2 a").
    is bringing back all the pieces that have that class with an anchor on the whole page, not just the ones in the .ms-wpContentDivSpace
    I don't know the exact syntax, but I think you need to iterate through all the '.ms_vb2 a' items as well - there are multiple ones, and do something like this inside your other grouping
    $(".ms-vb2 a").each(function(index) {
        var val=$(this).html();
       var val2=val.replace(/_/g," ")
       $(this).html(val2);
    That's not quite right but maybe that will help.
    Robin

  • TreeModel - Iterate through child records using row EL

    Hi all,
    Jdev Version: Studio Edition Version 11.1.1.7.0
    I have a search page where I need to display the search results of Header and on one of the columns need to display a concatenated list of children.
    Header is a Task and children are Assignees of the task. I am looking to achieve this by using a normal table bound to a tree binding inside which the 'Assignee' view link is added as a child. So the binding is ready. I attempt to use the af:table using the treeModel which also seems to be working fine.
    Now I am stuck on how to iterate through the assignees for each task using EL - #{row.???}
    Jsff  Code snippet
              <af:table value="#{bindings.Task1.treeModel}" var="row"
                          rows="#{bindings.Task1.rangeSize}"
                          summary="#{ResourcesGenBundle['Header.SearchResults']}"
                          varStatus="tableMetadata"
                          selectionListener="#{backingBeanScope.TaskSearchBean.selectHandler}"
                  width="100%" columnStretching="column:resId1c5" autoHeightRows="15">
                    <af:column id="c3" headerText="Assignees">
                        <af:iterator id="i1" rows="2" var="assigRow"
                                 value="#{row.Task11.collectionModel}">                 
                            <af:outputText value="#{assigRow.UserName}" id="ot2"/>
                            <af:spacer width="10" height="10" id="s2"/>
                        </af:iterator>
                    </af:column>
                </af:table>
    Page Def Snippet
        <tree IterBinding="Task1Iterator" id="Task1">
          <nodeDefinition DefName="sample.common.publicModel.components.view.TaskVO"
                          Name="Task10">
            <AttrNames>
              <Item Value="TaskId"/>
              <Item Value="Subject"/>
              <Item Value="Description"/>
              <Item Value="PastDue"/>
            </AttrNames>
            <Accessors>
              <Item Value="TaskUser"/>
            </Accessors>
          </nodeDefinition>
          <nodeDefinition DefName="sample.common.publicModel.components.view.TaskUserVO"
                          Name="Task11">
            <AttrNames>
              <Item Value="ListName"/>
              <Item Value="PersonId"/>
              <Item Value="UserRole"/>
            </AttrNames>
          </nodeDefinition>
        </tree>
    Thanks,
    Srini

    Trying out with
    <af:iterator id="i1" rows="2" var="assigRow"  value="#{row.children}">
    Will keep the thread posted on my progress. Meanwhile, any suggestions welcome .
    Another way I could think of achieving this is to not use a UI iterator and instead get the value for my outputText using a bean method where I could get the present row of the tree and get the children and concatenate the Assignee names and return. But UI iterator should be a better way to do this if possible. So still exploring.

  • Iterate through AS3 object

    Can anybody help me iterate through an Actionscript object in C
    The equivalant AS3 code would be:
    For (var key:String in someObject) {
    Thanks

    Hi,
    see this: https://blogs.oracle.com/groundside/entry/refresh_problems_using_adaptive_bindings
    Also, please read this:
    SQL injection - Wikipedia, the free encyclopedia
    Because this is what you will have to implement protection for to defend your database from damage.
    Frank

  • Iterate through XML find the missing element and prepare report

    Hi',
    I am reading a XML and if the ID is missing in that XML, then I have to make a report which can be send by mail
    by telling that these are the name for which ID is not present.
    I am able to iterate through the records and check if the ID is not present and pick the names for that,
    What I am not getting is how to put these names in a proper format.
    Like if I copy then each time the variable will be overwritten, if I use a append then a full new XML gets created.
    Please tell me how I can make a proper report.
    Thanks
    Yatan
    <Records>
    <Employee>
    <name>Yatan</name>
    <ID></ID>
    <Age>28</Age>
    </Employee>
    <Employee>
    <name>Yagya</name>
    <ID>101</ID>
    <Age>27</Age>
    </Employee><Employee>
    <name>Yugansh</name>
    <ID></ID>
    <Age>24</Age>
    </Employee>
    </Records>

    What about you do a XSLT transformation to get the email content in HTML format... That would avoid you to iterate through your XML...
    The template would be like this:
    <xsl:template match="/">
            <h2>These are the employees without ID</h2>
            <xsl:for-each select="/Records/Employee[ID = '']">
                <xsl:value-of select="name"/>
                <BR/>
            </xsl:for-each>
    </xsl:template>This is just a sample, syntax was not verified, but I think you'll get the idea...
    Please let me know if this was helpful...
    Cheers,
    Vlad

  • Iterate through selected characters

    Hi guys and girls!
    Has anybody a code snippet to show me how to iterate through the selected text (not the frame!, not the words, only the selected chars) and make any change on the characterAttributes (size, color, etc.)?
    Deeper into it:
    In the property "app.activeDocument.selection" usually the selected objects are stored as an array. Now when I select characters in a textframe (or TextPath, whatever) there is a [Textrange] in it.
    I already tried some combinations like this snippet underneath but I still get errors, that selectedChars[i] is undefined.
    FYI: I'm on Illustrator CS4, Mac OS X, Javascript
    var selectedChars = app.activeDocument.selection.characters;
    for (i = 0; i < selectedChars.length; i++ ){                           
         selectedChars[i].characterAttributes.fillColor = myNewCMYKColor;
    I hope I have gathered all relevant information. If not, please do not kill me and just ask back
    So has anybody a smart hint for me?
    Thanks a lot in advance!

    Here's a Change Size script that I found in my collection that somebody posted severat years ago. I'm sorry I don't remember who it was to give proper credit.
    #target illustrator
    // change size of paragraph text
    //$.bp();
    ChangeSize();
    function ChangeSize()
        selectedItems = selection;
        // check to make sure something is selected.
        if (selectedItems.length == 0)
            alert("Nothing is selected");
            return;
        endIndex = selectedItems.length;
        for (index = 0; index < endIndex; index++)
            pageObject = selectedItems[index];
            pageItemType = pageObject.typename;
            if (pageItemType == "TextFrame")
                // get the paragraphs from the selection.
                theTextRange = pageObject.textRange;
                paraTextRange = theTextRange.paragraphs;           
                numParagraphs = paraTextRange.length;
                for (i = 0 ; i < numParagraphs ; i++)
                    aParagraph = paraTextRange[i];
                    charTextRange = aParagraph.characters;
                    charCount = charTextRange.length;
                    if (charCount > 1)
                        end = charCount;
                        fontSizeChanger = 14/end;
                        currentFontSize = 18;
                        for (j = 0 ; j < end; j++)
                            theChar = charTextRange[j];
                            theChar.size = currentFontSize;  
                            currentFontSize = currentFontSize - fontSizeChanger;
    and here's the output.
    You should be able to go from there.

  • Iterating through fields in object

    Is there a way for me to iterate through the fields in an object?
    I have a helper class that basically contains several variables with assigned values.
    How can I iterate through the variables in this class?
    I basically want to check the contents and re-assign a value as I loop through.
    Thanks

    Here is what I am really trying to accomplish.
    I have a jsp that is get back values from the database.
    Before I attempt an update, I retrieve the record from the database.
    The fields that are showing up blank in Oracle. Nulls are allowed.
    When the record is retrieved, my jsp shows null in the text box after I do a setAttribute.
    The problem is that the "null" is text. So now when I actually update to the database,
    I end up with a text string that says "null" instead of actually having a null value in the database for that field.
    So I need some sort of null check before I populate my jsp, so that I can just have a blank field and I think that would solve my problem.
    Thanks

  • Iterate through list

    i have a list and i want to iterate through the list and get the names of the classes present in that..
    i have the following code
    Iterator it= list.iterator();
    String value;
    while(it.hasNext())
         Object obj= it.next();
         Class cls= obj.getClass();
         value = cls.getName();
    now if i want to check whether a class called test is present in that list how to do that...pls help

    mgv wrote:
    i have a list and i want to iterate through the list and get the names of the classes present in that..
    i have the following code
    Iterator it= list.iterator();
    String value;
    while(it.hasNext())
         Object obj= it.next();
         Class cls= obj.getClass();
         value = cls.getName();
    now if i want to check whether a class called test is present in that list how to do that...pls help
    while(it.hasNext()){
    Object obj = it.next();
    if(obj instanceof test){
        //do something
    }

Maybe you are looking for