you can make a model that wraps both and returns result { boolean master, object value }
then you bind your textfield with ("setting.value") and your checkbox/flag with "setting.master" -igor On Jan 30, 2008 4:49 PM, Sam Barnum <[EMAIL PROTECTED]> wrote: > I'm writing an settings admin page for editing a bunch of Boolean > settings. I'm using a custom component to edit the boolean values. > This custom component needs access to two settings objects > (masterSettings, customSettings) to determine if a custom setting is > overridden by a master setting. > > some pseudocode: > > public class SettingsEditPage extends WebPage { > > public SettingsEditPage(Settings masterSettings, Settings > customSettings) { > Model masterModel = new CompoundPropertyModel(new > LoadableDetachableModel(masterSettings){/* load method omitted */}); > Model cutomModel = new CompoundPropertyModel(new > LoadableDetachableModel(customSettings){/* load method omitted */}); > // > add(new SettingsEditComponent("canDeleteWidgets", masterModel, > customModel)); > add(new SettingsEditComponent("canCreateWidgets", masterModel, > customModel)); > add(new SettingsEditComponent("allowsReturns", masterModel, > customModel)); > } > } > > I'd like to use the component id for the SettingsEditComponent as a > property expression, like in a CompoundPropertyModel. This would be > used to query the master settings first. If that returns null, use > the value from the custom settings. I also need the ability to > display to the user whether a value came from the masterSettings or > customSettings. > > It's not clear to me what the best way to architect this is. > > Should I make a custom model that wraps both the masterSettings and > customSettings objects? It would need a boolean method to determine > whether a given propertyExpression is taken from the master or custom > settings. If I do this, the SettingsEditComponent constructor would > need to only accept that specific model type (or an interface with > the boolean method, which is overkill). > > Or, should I pass both settings objects into the > SettingsEditComponent, as pictured above? It seems like it would be > harder to have detachable models in this case (I guess I'd just need > to override detatchModels()). > > Or, some other option that I'm missing... > > Thanks! > > -- > Sam Barnum > http://www.360works.com > 415.865.0952 > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]