BO's/Design for Dynamic UI

BO's/Design for Dynamic UI

Old forum URL: forums.lhotka.net/forums/t/3985.aspx


cliffordru posted on Wednesday, December 05, 2007

I am curious how others have approached this design issue.  If you have a web form that needs to dynamically display different UI elements based on what is selected in say a drop down, how is this best handled?  For example if you have a drop down and if the user selects value 1, you would then need to display a text box and a set of radio buttons, but if they select value 2, they should see 2 additional drop downs, 2 text boxes, etc.  There will be many permutations and they will be stored either in xml or a database.

If using CSLA, would a good design include creating a read only list class, say UIElementList that had a child collection of UIElementItem’s?  The UIElementItem would correlate to a UI control, for example a text box or radio button list, and have properties correlating to what is needed to create the UI.  UIElementList’s responsibility would then be to display the UI elements.  If taking this approach, would manually looping through the collection to create the UI be the only option or would direct data binding be possible?

If anyone has an alternative approach, I would be interested in hearing about it.  Thanks.

richardb replied on Thursday, December 06, 2007

I kind of did something similar (albeit in a Windows form) when I was creatting a dynamic UI for selecting Reports.  Depending on the report chosen, the selection criteria available differed.

So I created a Report object with ReportParams child objects, looped through them to see what type of control I should draw on the form and then bound that control to a property on my business object to remember what value they'd chosen as the parameter.

I happended to store these in a SQL database but an XML file is just as good.

I also stored some SQL code for any parameters that needed lookup data (e.g. list of countries if the report had a country filter) - so I could populate a combo control with values.  That was a bit rubbish and lazy but if I'd had a bit more time I'd have made it use a lookup business object instead.

Richard B.

DavidDilworth replied on Thursday, December 06, 2007

We have met a similar style of requirement by using a PlaceHolder and User Controls.  So depending on the selected value from the drop down, we load a different User Control into the PlaceHolder.

Each User Control can then be as simple or as complex as required.

Copyright (c) Marimer LLC