Hi Joe, Ignoring the workflow issues: On the edit page you could use something like: ERDEditStringWithChoices I modified ERDEditStringWithChoices so that you can use a key path as well as a dictionary or array in the rules (not thoroughly tested). You may want to clone ERDEditStringWithChoices and customize it instead: Object choices = valueForBinding("possibleChoices"); if(choices != null) { NSMutableArray keyChoices = new NSMutableArray(); // choices will be a string if you have specified a keyPath in the rules if(choices instanceof String) { String possibleChoices=(String)d2wContext().valueForKey("possibleChoices"); if( possibleChoices!=null && possibleChoices.length()>0 ) // get the value for the keyPath choices = (NSDictionary)valueForKeyPath(possibleChoices); } // This results in choices being a NSDictionary grabbed from the keyPath provided. // Now you can use it as if it came from the rules: if(choices instanceof NSArray) { for(Enumeration e = ((NSArray)choices).objectEnumerator(); e.hasMoreElements(); ) { NSDictionary dict = (NSDictionary)e.nextElement(); String key = (String)dict.allKeys().lastObject(); String value = (String)dict.objectForKey(key); keyChoices.addObject(new ERXKeyValuePair(key, ERXLocalizer.currentLocalizer().localizedStringForKeyWithDefault(value))); } } else if(choices instanceof NSDictionary) { NSArray keys = ((NSDictionary)choices).allKeys(); keys = ERXArrayUtilities.sortedArraySortedWithKey(keys, "toString"); for(Enumeration e = keys.objectEnumerator(); e.hasMoreElements(); ) { String key = (String)e.nextElement(); String value = (String)((NSDictionary)choices).objectForKey(key); keyChoices.addObject(new ERXKeyValuePair(key, ERXLocalizer.currentLocalizer().localizedStringForKeyWithDefault(value))); } } _availableElements = keyChoices; } Specifying the key path should give you the flexibility to programatically create a dictionary of values you need for your popup from current company.Affiliates Again a simple example of a method I put in my session to illustrate: public NSDictionary writtenLanguagePreference() { NSMutableDictionary writtenLanguagePreference = new NSMutableDictionary(); writtenLanguagePreference.setObjectForKey("English", "English"); writtenLanguagePreference.setObjectForKey("Spanish","Spanish"); return (NSDictionary)writtenLanguagePreference; } And the associated rules: 110 : (pageConfiguration = 'ZZZ' and propertyKey = 'language') => componentName = "ERDEditStringWithChoices" [com.webobjects.directtoweb.Assignment] 110 : (pageConfiguration = 'ZZZ' and propertyKey = 'language') => possibleChoices = "session.writtenLanguagePreference" [com.webobjects.directtoweb.Assignment] Results in this UI: ![]() ![]() And a string stored in the database: ![]() HTH, David On 2011-02-15, at 11:50 PM, Mark Wardle wrote:
|
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com