Hi,

So I cleaned it up a little bit...

I created as assignment that has methods like this:

    protected NSDictionary<String, Object> resolveBindings(D2WContext context, 
NSDictionary bindings) {
        NSMutableDictionary<String, Object> resolvedBindings = new 
NSMutableDictionary<String, Object>();
        for(Object key : bindings.allKeys()) {
                String aKey = (String) key;
                Object value = context.valueForKeyPath((String) 
bindings.objectForKey(aKey));
                if(value != null) {
                        resolvedBindings.takeValueForKey(value, aKey);
                }
        }
        return resolvedBindings;
    }
        
        @Override
        public Object fireNow(D2WContext c) {
                Object result = null;
                Object value = value();
                if(value != null && value instanceof NSDictionary) {
                        result = resolveBindings(c, (NSDictionary) value);
                }
                return result;
        }

And then I updated my restritedChoiceList method to look like this:     

        EOEditingContext ec = ERXEC.newEditingContext();
            EOEntity entity = d2wContext().entity();
            EORelationship relationship = entity.relationshipNamed((String) 
d2wContext().valueForKey("propertyKey"));
            NSDictionary bindings = 
(NSDictionary)d2wContext().valueForKey("restrictingFetchSpecificationBindings");
            
            ec.lock();
            try {
                return EOUtilities.objectsWithFetchSpecificationAndBindings(ec,
                        relationship.destinationEntity().name(), fetchSpecName, 
bindings);
            } finally {
                ec.unlock();
            }

And it works...

Any comments/advice would be appreciated!

Thanks,

Johnny

On May 4, 2013, at 1:20 PM, Johnny Miller <jlmil...@kahalawai.com> wrote:

> Hi Bastian,
> 
> I was thinking the same thing but ERDDelayedKeyValueAssignment with the 
> qualifier format just blew up.  It returned an error that didn't make much 
> sense like couldn't resolve componentName or something to that effect.
> 
> So I did something that is pretty lame.  I created two keys - one for the 
> left side one for the right (this is my subclass of 
> ERD2WQueryToOneRelationship) i.e. 
> 
>             String key = 
> (String)d2wContext().valueForKey("restrictingFetchSpecificationKey");
>             Object value = 
> d2wContext().valueForKey("restrictingFetchSpecificationValue");
>             NSDictionary<String, Object> bindings = null;
>             
>             if(key != null && value != null) {
>               bindings = new NSDictionary<String, Object>(
>                               new NSArray<Object>(new Object[] {value}), 
>                               new NSArray<String>(new String[] {key}));
>             }
>             
>             ec.lock();
>             try {
>                 return 
> EOUtilities.objectsWithFetchSpecificationAndBindings(ec,
>                         relationship.destinationEntity().name(), 
> fetchSpecName, bindings);
>             } finally {
>                 ec.unlock();
>             }
> 
> And that works but it's pretty ugly.  I guess I could create a custom 
> assignment that creates a NSDictionary?  I guess I will look at 
> ERDDelayedExtraQualifierAssignment for a start.
> 
> Thank you!
> 
> Johnny
> 
> On May 4, 2013, at 9:19 AM, Bastian Triller <bastian.tril...@gmail.com> wrote:
> 
>> Maybe an ERDDelayedKeyValueAssignment for restrictingfetchspecification with 
>> extraRestrictingQualifier as value?
>> 
>> On Sat, May 04, 2013 at 08:22:10AM -1000, Johnny Miller wrote:
>>> Yeah, I'm wondering if there is a way to do a restrictingfetchspecification 
>>> where I pass in an object at runtime i.e. a session object.   I'm going to 
>>> try to subclass erd2wlistpage and use 
>>> eoutilities.objectswithfetchspecificationandbindings and create a key in 
>>> the d2wcontext that I can use for the bindings.
>>> 
>>> Do you know how to create a nsdictionary from a rule?
>>> 
>>> Thanks,
>>> 
>>> Johnny
>>> 
>>> Sent from my iPad
>>> 
>>> On May 4, 2013, at 12:32 AM, Theodore Petrosky <tedp...@yahoo.com> wrote:
>>> 
>>>> Johnny,
>>>> 
>>>> So in my Entity Modeler I have a fetchSpecifiction called 'activeUsers' on 
>>>> my Users entity, then in my rules I have:
>>>> 
>>>> 110 : (pageConfiguration like '*Embedded*' and propertyKey = 'user') => 
>>>> restrictingFetchSpecification = "activeUsers" 
>>>> [com.webobjects.directtoweb.Assignment]
>>>> 
>>>> my popup contains only the list from the fethchSpecification.
>>>> 
>>>> does that help?
>>>> 
>>>> Ted
>>>> 
>>>> 
>>>> --- On Fri, 5/3/13, Tim Worman <li...@thetimmy.com> wrote:
>>>> 
>>>>> From: Tim Worman <li...@thetimmy.com>
>>>>> Subject: Re: D2W restrictingFetchSpecification Question
>>>>> To: "Johnny Miller" <jlmil...@kahalawai.com>
>>>>> Cc: "WebObjects-Dev Apple" <Webobjects-dev@lists.apple.com>
>>>>> Date: Friday, May 3, 2013, 11:19 PM
>>>>> Hi Johnny:
>>>>> 
>>>>> I haven't used the restrictingFetchSpecification before. But
>>>>> I have used a query data source delegate that implements
>>>>> ERDQueryDataSourceDelegateInterface. There's an example on
>>>>> the wiki on the wiki in the D2W flow control article. You
>>>>> may already know about that option - but throwing it out
>>>>> just in case.
>>>>> 
>>>>> http://wiki.wocommunity.org/display/documentation/D2W+Flow+Control
>>>>> 
>>>>> Tim
>>>>> 
>>>>> On May 3, 2013, at 8:12 PM, Johnny Miller <jlmil...@kahalawai.com>
>>>>> wrote:
>>>>> 
>>>>>> Hi,
>>>>>> 
>>>>>> I want to add an automatic qualifier binding to a
>>>>> number of my list pages.
>>>>>> 
>>>>>> And I'm just not quite getting how to use the
>>>>> restrictingFetchSpecification key.  
>>>>>> 
>>>>>> If I want my qualifier to be based upon an object in my
>>>>> session how do I create the qualifier?  I see that I
>>>>> can put a variable in the qualifier that gets created in the
>>>>> EOModel but how do I tell D2W to substitute the variable
>>>>> with my session object at runtime?
>>>>>> 
>>>>>> Thanks in advance,
>>>>>> 
>>>>>> Aloha,
>>>>>> Mr. Johnny Miller
>>>>>> Web Development Manager
>>>>>> Kahalawai Media Company
>>>>>> Lahaina, HI 96761
>>>>>> tel: (808) 661-7962 | mobile: (808) 283-0791
>>>>>> website | e-mail    
>>>>>> 
>>>>>> _______________________________________________
>>>>>> 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:
>>>>>> https://lists.apple.com/mailman/options/webobjects-dev/lists%40thetimmy.com
>>>>>> 
>>>>>> This email sent to li...@thetimmy.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:
>>>>> https://lists.apple.com/mailman/options/webobjects-dev/tedpet5%40yahoo.com
>>>>> 
>>>>> This email sent to tedp...@yahoo.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:
>>> https://lists.apple.com/mailman/options/webobjects-dev/bastian.triller%40gmail.com
>>> 
>>> This email sent to bastian.tril...@gmail.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:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to