12 Replies Latest reply on Sep 23, 2008 2:39 AM by Karl_Sigiscar_1971

    Can Flex do dynamic UI like AJAX?

    Capital_Idea
      With CGI or AJAX apps, if I want a checkbox for each of a number of items returned by the server, I can just have the server spit out a bunch of checkbox HTML elements, then set them as the innerHTML for some div.

      Since Flex is compiled, it doesn't seem like this is possible. Is there a way to have any number of checkboxes dynamically generated based on output from a server?
        • 1. Re: Can Flex do dynamic UI like AJAX?
          riesvantwisk
          You can create any component on the fly if you want to much like how you would using DOM in HTML.

          Ries
          • 2. Re: Can Flex do dynamic UI like AJAX?
            Level 7

            "Capital Idea" <webforumsuser@macromedia.com> wrote in message
            news:g913mu$qkf$1@forums.macromedia.com...
            > With CGI or AJAX apps, if I want a checkbox for each of a number of items
            > returned by the server, I can just have the server spit out a bunch of
            > checkbox
            > HTML elements, then set them as the innerHTML for some div.
            >
            > Since Flex is compiled, it doesn't seem like this is possible. Is there a
            > way
            > to have any number of checkboxes dynamically generated based on output
            > from a
            > server?

            Look at Repeaters and List based components.

            HTH;

            Amy


            • 3. Re: Can Flex do dynamic UI like AJAX?
              trustme73
              I have a similar requirement. Have you got an answer for this?
              • 4. Re: Can Flex do dynamic UI like AJAX?
                yigitt Level 1
                definitely yes, actually it is what flex is ,since it was flash with actionscript...

                but generally flex developers choose to use built in repeater classes rather than creating them with pure as3 code (like you do in java swing, javascript DOM etc). Of course you can choose both according to your needs...

                and I give my word that it is much much more easier&faster in flex with respect to javascript bcuz my company has chosen client side javascript generation and I know how much it sucks...
                • 5. Re: Can Flex do dynamic UI like AJAX?
                  trustme73 Level 1
                  My requirement is slightly different. I am generating a html layout in the server(html form with the list of input boxes and buttons). When the browser receives this layout it just renders the page. I want to convert this to flash UI. But flash has swf file which is complied. How can i convert html page to flash ui(swf file)?. Here the html page is dynamically generated one and the number of controls and the layout info will be decided at runtime.

                  Thanks for the info in advance.
                  • 6. Re: Can Flex do dynamic UI like AJAX?
                    yigitt Level 1
                    there are many ways to do it, but basically, you should pass the information to flex to create the form. For example you can use XML for data transfer. Flex has a built in XML parser. So you can traverse through the XML to create a form object for to show. After the user fills the form, you can recreate the XML with data in it and post back to server.
                    • 7. Re: Can Flex do dynamic UI like AJAX?
                      trustme73 Level 1
                      Thanks for the details. Can I create text input control "<mx:TextInput" dynamically without placing text input control in mxml file and compiling into swf? I want to generate a form dynamically with different set of controls depends on the user input. I don't want to keep multiple forms designed in design time to support this. Please direct me to some link where I can get details about this.
                      • 8. Re: Can Flex do dynamic UI like AJAX?
                        Level 7

                        "trustme73" <webforumsuser@macromedia.com> wrote in message
                        news:g95ksf$32n$1@forums.macromedia.com...
                        > My requirement is slightly different. I am generating a html layout in the
                        > server(html form with the list of input boxes and buttons). When the
                        > browser
                        > receives this layout it just renders the page. I want to convert this to
                        > flash
                        > UI. But flash has swf file which is complied. How can i convert html page
                        > to
                        > flash ui(swf file)?. Here the html page is dynamically generated one and
                        > the
                        > number of controls and the layout info will be decided at runtime.

                        If your HTML is valid XHTML, you should be able to use e4x to walk the tree
                        and display equivalent items. But since you have it working, why not just
                        leave it alone?


                        • 9. Re: Can Flex do dynamic UI like AJAX?
                          yigitt Level 1
                          YES!
                          quote:

                          Originally posted by: trustme73
                          Thanks for the details. Can I create text input control "<mx:TextInput" dynamically without placing text input control in mxml file and compiling into swf? I want to generate a form dynamically with different set of controls depends on the user input. I don't want to keep multiple forms designed in design time to support this. Please direct me to some link where I can get details about this.


                          • 10. Re: Can Flex do dynamic UI like AJAX?
                            trustme73 Level 1
                            The browser support for E4X is limited. I want to support all the browsers. How can I achieve this?
                            • 11. Can Flex do dynamic UI like AJAX?
                              cemef
                              I have a better idea for solving all the problems mentioned in this topic. Sometimes it's much better to write a little code in pure Action Script, for example something like "public class myComboBox extends ComboBox". Then you can add everything dynamically anytime you want using addChild(new myComboBox()).
                              • 12. Can Flex do dynamic UI like AJAX?
                                Karl_Sigiscar_1971 Level 3
                                Because Flash Player uses ActionScript E4X and not Javascript E4X, it is compatible with all browsers (even those that do not support E4X).

                                The best approach for what's discussed in this topic is to use a List based control with an item renderer, as Amy pointed out.