8 Replies Latest reply on Aug 28, 2008 11:23 AM by vikceo

    custom component design question

    vikceo Level 1
      I have a xml file having children upto two levels. I want read this xml file and create each parent node as a form with all the underlying children as form items (say labels)...

      what is suggested way to achieve that?

      struct of xml is like
      <tasks>
      <task>
      <attr1>val1</attr1>
      <attr2>val2</attr2>
      ...
      <actions>
      <action1>act1</action1>
      <action2>act2</action2>
      </actions>
      </task>
      <task>
      ....
      </task>
      </tasks>
        • 1. Re: custom component design question
          Level 7

          "vikceo" <webforumsuser@macromedia.com> wrote in message
          news:g925co$cnh$1@forums.macromedia.com...
          >I have a xml file having children upto two levels. I want read this xml
          >file
          > and create each parent node as a form with all the underlying children as
          > form
          > items (say labels)...
          >
          > what is suggested way to achieve that?
          >
          > struct of xml is like
          > <tasks>
          > <task>
          > <attr1>val1</attr1>
          > <attr2>val2</attr2>
          > ...
          > <actions>
          > <action1>act1</action1>
          > <action2>act2</action2>
          > </actions>
          > </task>
          > <task>
          > ....
          > </task>
          > </tasks>

          Probably the easiest way is nested repeaters.

          HTH;

          Amy


          • 2. Re: custom component design question
            vikceo Level 1
            could you please elaborate a bit on this.. keeping the given xml in this post as example?
            • 3. Re: custom component design question
              Level 7

              "vikceo" <webforumsuser@macromedia.com> wrote in message
              news:g94pd7$3vc$1@forums.macromedia.com...
              > could you please elaborate a bit on this.. keeping the given xml in this
              > post as example?

              What is the final look you are going for?


              • 4. Re: custom component design question
                vikceo Level 1
                good question...

                Well after reading this data into a 2 D metrix (or whatever flex names this).. i have to pass every row of this metirx into a custom component.

                And the component will generate a form having all the individual column of the row as a formItem.

                So, it is basically a dynamic UI based on that xml file.

                Please suggest if this is the right approach and if yes then how to achieve it.

                My progress on it is: i can read the xml properly. and also based on a passed row to my component i can generate a form as desired.

                But, I am not able to create a structure in which i can put the values after reading from the xml and to pass it row wise to my component.
                • 5. Re: custom component design question
                  Level 7

                  "vikceo" <webforumsuser@macromedia.com> wrote in message
                  news:g955os$hhv$1@forums.macromedia.com...
                  > good question...
                  >
                  > Well after reading this data into a 2 D metrix (or whatever flex names
                  > this)..
                  > i have to pass every row of this metirx into a custom component.
                  >
                  > And the component will generate a form having all the individual column of
                  > the
                  > row as a formItem.
                  >
                  > So, it is basically a dynamic UI based on that xml file.
                  >
                  > Please suggest if this is the right approach and if yes then how to
                  > achieve it.
                  >
                  > My progress on it is: i can read the xml properly. and also based on a
                  > passed
                  > row to my component i can generate a form as desired.
                  >
                  > But, I am not able to create a structure in which i can put the values
                  > after
                  > reading from the xml and to pass it row wise to my component.

                  So, if I'm getting you correctly, what you want is one form for each record,
                  and one form control for each "field"?

                  You could do something like this:

                  <mx:ViewStack id="allForms">
                  <mx:Repeater id="formRepeater" dataProvider="{yourXML.children()}">
                  <mx:Form id ="formsArray"
                  label="{formRepeater.currentItem.name()}">
                  <mx:Repeater id="formItemRepeater"
                  dataProvider="{formRepeater.currentItem.children()>
                  <mx:FormItem id="formItemArray"
                  label="{formItemRepeater.currentItem.name()}">
                  <mx:TextInput
                  text="{formItemRepeater.currentItem.text()}"/>
                  </mx:FormItem>
                  </mx:Repeater>
                  </mx:Form>
                  </mx:Repeater>
                  </mx:ViewStack>

                  Note that this is not going to get you 100% of the way to your goal...it's
                  not going to properly display the full depth of the actions item, and I
                  didn't do anything to ake your XMLLists into XMLListCollections, so it's
                  going to give you errors about not being able to detect changes in
                  assignment yadda yadda. But it should make it so that you can read the docs
                  yourself and figure the rest out.

                  HTH;

                  Amy


                  • 6. Re: custom component design question
                    vikceo Level 1
                    yes i want to create one form per line or record and this is good sample for doing what I need.

                    But Amy, can i make it a bit generic? I mean say i have to pass individual row to a custom component which will render this form at place i want in my mxml?
                    • 7. Re: custom component design question
                      Level 7

                      "vikceo" <webforumsuser@macromedia.com> wrote in message
                      news:g96m2j$9bn$1@forums.macromedia.com...
                      > yes i want to create one form per line or record and this is good sample
                      > for
                      > doing what I need.
                      >
                      > But Amy, can i make it a bit generic? I mean say i have to pass individual
                      > row
                      > to a custom component which will render this form at place i want in my
                      > mxml?

                      There are plenty of generic examples in the help. I made you a specific
                      one, because that is what you asked for. No offense, but I think I'll spend
                      my time helping people who are more successful at taking my suggestions and
                      extrapolating them to move forward.


                      • 8. Re: custom component design question
                        vikceo Level 1
                        I do agree.. Amy.. I am working on this my stuff for last 2 months and doing every possible thing..

                        I asked you that question coz i have tried creating a mxml compoent which can render me the stuff i asked you above.. But the problem is I am not able to pass a collection in my mxml based custom component.

                        I am getting null every time..

                        After a lot of tries I also could not solve the problem of creating a two dimensional matrix in which i can populate my xml as per node as row and all attributes as children. However, I can read the xml data from the source...

                        So, I am trying to solve a big problem and to save time of people here asking in parts and give that part a try first..