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:

Hi Joe.

I may have interpreted this incorrectly but I'll try some suggestions.

I don't think your issue is a D2W problem per se.

I would consider this a modelling one - if a membership is linked to a
user but you want some details copied in to the membership on
creation, then can't you do that as part of the setUser() setter in
your membership with a check not to overwrite if there's already  a
value for that (those) properties.

Mark

--
Dr. Mark Wardle
Specialist registrar, Neurology
(Sent from my mobile)


On 16 Feb 2011, at 05:49, Joe Little <jmlit...@gmail.com> wrote:

Ok, I'll try to give a more specific example.

I have a Membership entity with such properties as beginDate, endDate,
company (relationship) and primaryContactName and primaryContactEmail.
The end users want to select these last two values from a pull down
list of known company.Affiliates, where Affiliates are people with
name, email, etc.

However, affliates move around so they want to store those values
relative to one this membership whenever its created, so five years
from now, those values stick. A slightly better example is Projects
who have among other thing a String property of VisitingScholar or
Fellow, which is just the name of an Affiliate again. In the same way,
they want this name to stick with project even if that Affiliate
changes companies or disappears altogether. I've done this before, but
have no clue of how to do this with D2W. I want one to be able to set
the value when say primaryContactName == null via a pull down of
current company.Affiliates if company itself is != null, and then
later, allow for just standard text field manipulation.


On Tue, Feb 15, 2011 at 9:17 PM, David Holt <programming...@me.com> wrote:
I'd love to help but this makes no sense to me at all.

Can you be more specific? What are your entities?


On 2011-02-15, at 8:49 PM, Joe Little <jmlit...@gmail.com> wrote:

I want the certain fields (String) to take the values from a pull down
from another Entity, inserting Entity.name or Entity.type for the
string on selection. I don't want a relation since the choices are to
be archival and not reflect what Entity.type is presently, but what it
was at time of creation/edit. I was wondering how this is normally
done with D2W rules. Also, I was hoping to do this on initial setting
of the property only, but allow free-form editing when not null. I'm
presuming pull downs like this are par for the coarse, but haven't
found ready examples to point me to the right d2w keys.
_______________________________________________
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/programmingosx%40mac.com

This email sent to programming...@mac.com

_______________________________________________
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/mark%40wardle.org

This email sent to m...@wardle.org
_______________________________________________
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/programmingosx%40mac.com

This email sent to programming...@mac.com

 _______________________________________________
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

Reply via email to