XML-Driven Flex UI

I saw a recent post from Ted over at PowerSDK about dynamically generating a Flex UI from an XML document. This has actually been a moderately requested capability from some customers. For the most part, customers request the functionality because they make heavy usage of server-side business logic. This breaches the debate about how much logic should go into a Flex application on the client, and what the nature of that logic should be, which is a topic I’ll gracefully skirt for now.

One of my customers who made this request back in the Flex 1.0 days (like it was such a long time ago) already had an XML DTD they used for their applications. The business tier would generate the XML and the client would parse and build the UI as appropriate to the display mechanism. In this fashion, they could generically describe their application user interfaces that might ultimately end up running on anything from the browser to a WAP-enabled device.

It was a natural next step to have Flex perform the same processing.

I spent a couple days onsite with this customer going over how Flex works, and then building out an example of how Flex might leverage their existing XML. This example even takes the next step of gathering data from the dynamically generated UI, and delivering it back to an awaiting JSP. I’ve cleansed the code such that it doesn’t make any customer-specific references and posted the example here for your enjoyment - with a few caveats.

First note that as mentioned, this example was developed very shortly after the release of Flex 1.0. There are likely many changes that could/should be made to update the code for Flex 1.5. Second is that this code is rather incomplete. The example does a good job at giving you an idea of how Flex might parse and render a UI-related XML document, but that’s it. Finally you should be aware that driving your entire UI like this is not without its potential pitfalls. Take for example that Flex’s validation capabilities are expected to be implemented declaratively and not dynamically at runtime.

XML-Driven UI

WordPress database error: [Can't open file: 'wp_comments.MYI' (errno: 145)]
SELECT * FROM wp_comments WHERE comment_post_ID = '51' AND comment_approved = '1' ORDER BY comment_date

Leave a Reply