Re: Binding query variables (EOF Fetch Spec Qualifier) under IB

Ryan Poling <[email protected]> Tue, 1 Mar 2005 08:48:32 -0800
Newsgroups gmane.comp.web.webobjects.eof
Message-ID <[email protected]>
Hi,

Okay, I think I understand your problem now.  Unfortunately, our 
program doesn't use any fetch specifications defined in the EOModel, so 
I don't know how to help you with that.  In the cases where I've needed 
to alter a fetch specification from the default one which IB produces, 
I've done it in the code - not in the model.

In fact, I think I've just used the EODisplayGroup.Delegate method 
called 'displayGroupDisplayArrayForObjects' to alter which items are 
displayed.

I'd be curious to hear if you figure it out though.

Good luck.

-Ryan

On Mar 1, 2005, at 8:28 AM, fe wrote:

>
>
> I'll try to be more explicit.
> What I've succesfully done is stuff about EOTextAssociation/value for
> editing and @query= for searching the base, like you talked about.
>
> What I can't find how to do is:
> I can't use the Fetch Specification I've created on my table (under
> EOBuilder) In that FetchSpec, I've created a Qualifier
>
>     (name = $aName)
>
> So I have to bind some NSTextField to the Qualifier Variable $aName
> And I just don't know how. I the docs they talk about a @queryBindings
> (for  WOBuilder) or a @bindings (for IB). I suspect I should have
> The @bidings->aName in the inspector where there is @query= and 
> @query>.
> But there isn't!!!
>
> Though, in the screen shots of WOBuilderin the docs, I can see the
> @querybingins->queryVars and @queryMatch (which should be the IB's 
> @query=)
> in the same inspector!
>
> So I think I've missed something ...
>
> I hope I was more clear so may be you can help me more!
>
> Regards,
>
>     Ryu
> On 1/03/05 17:11, "Ryan Poling" <[email protected]> wrote:
>
>> Hi,
>>
>> Maybe I'm missing what your problem is, but I've been successful
>> binding interface items to use for queries in Interface Builder.  I'm
>> building a Java Client App, but I think it would be the same for you.
>>
>> Here's what I do:
>>
>> - Control drag and connect from text field to EODisplayGroup in IB 
>> main
>> window.
>> - From EOTextAssociation in the inspector, choose 'value'.
>> - The query variables are at the bottom of the list if you scroll down
>> - things like '@query=', '@query>', etc.
>>
>>  From what I've seen - it's possible to bind the fields in two ways.
>>
>> 1.  You can have fields dedicated only to queries - bind them up as
>> described above.  These will form a query whenever you send the 
>> display
>> group the qualifyDataSource message (you can bind this up through a
>> button for example).  I'm only using this in one place, but it seems 
>> to
>> work okay.
>>
>> 2.  You can use the same text fields for display as for query.  This 
>> is
>> mostly what we do - connect up a button and have it send the
>> enterQueryMode message to your display group.  When in query mode, the
>> text fields will act as qualifiers for your query - when in edit mode,
>> they display data from the currently selected EOEnterpriseObject in
>> your display group.  This has worked fairly well for us.
>>
>> Another thing that may help you - I've seen similar error messages to
>> yours when I tried to hook up a query field to an instance variable in
>> my EO subclass which wasn't actually present in the EOModel.  So I
>> think you can only do queries on fields that are in the EOModel.
>>
>> Hope that helps.
>>
>> -Ryan
>>
>>
>> On Mar 1, 2005, at 1:14 AM, Ryu wrote:
>>
>>>
>>> I'm using OSX, and up to now Cocoa/EOF, but it's ok me for me
>>> to use Java and make a Java Client Application. (Anyway, up to
>>> Now I don't have a line of code, so I think it doesn't change 
>>> anything
>>> if using ObjC or Java)
>>>
>>> Hence, I use EOBuilder to build my database, and Interface builder
>>> To build my interface.
>>>
>>> It is quite frustrating because I'm sure we can do the bindings
>>> graphically
>>> under IB, exactly like it is shown under WebObjectBuilder (there are
>>> even
>>> Screenshots in the docs! And they say it's the same under IB).
>>>
>>> PS: in my last mail, I said:
>>>
>>>>> code. I already successfully wrote a front end that can browse all
>>>>> elements,
>>>>> and add/remove/modify an entry with writing code.
>>>
>>> I wanted to say that I could do this WITHOUT writing anycode, and 
>>> that
>>> I expected to do so for such a simple think as binding Query 
>>> Variables
>>> Of my Qualifier to interface elements (NSTextFied)
>>>
>>>
>>>
>>> New point:
>>>
>>> As I couldn't find "how to" bind my query variables to my interface
>>> Objects (TextFields...) using InterfaceBuilder, I tried to make it
>>> Programmatically using Objc, but it seems there are some pbs :-(
>>>
>>> my fetch spec looks like
>>>
>>>      (name = $name)
>>>
>>> And the code:
>>>
>>>     fetch = [[displayGroup dataSource] fetchSpecification];
>>>     qual = [fetch qualifier];
>>>     bindings = [NSMutableDictionary new];
>>>     [bindings takeStoredValue: @"Baka" forKey: @"name"];
>>>
>>> And
>>>
>>>     q2 = [qual qualifierWithBindings: bindings : NO];
>>>
>>> Makes:
>>>
>>> 2005-02-25 11:52:26.206 Baka[808]
>>> com/webobjects/foundation/NSKeyValueCoding$UnknownKeyException:
>>> <com.apple.cocoa.foundation.NSMutableDictionary 0xbf47df>
>>> valueForKey():
>>> lookup of unknown key: 'name'.
>>> This class does not have an instance variable of the name name or
>>> _name, nor
>>> a method of the name name, _name, getName, or _getName
>>>
>>> The same way,
>>>
>>>      fetch = [fetch fetchSpecificationWithQualifierBindings: 
>>> bindings];
>>>
>>> Or
>>>
>>>     [[displayGroup dataSource] setQualifierBindings: bindings];
>>>
>>> Make exactly the same error!
>>>
>>> I was said the was a Javabridge problem, but I just don't know ...
>>> I think I'm gonna try to make excatly the same code in Java using
>>> a Java Client Application to compare ...
>>>
>>>
>>> Any help is greatly appreciated!!!
>>>
>>> Regards,
>>>
>>>     Ryu
>>>
>>>
>>> On 28/02/05 18:13, "Ricardo Strausz" <[email protected]> wrote:
>>>
>>>> Hola Ryu!
>>>> can you be more specific... which platform are you using?
>>>> You mentioned Interface Builder; are you trying Java Client? or
>>>> Cocoa/EOF?
>>>>
>>>> Dino
>>>>
>>>> On Feb 21, 2005, at 10:28 AM, Ryu wrote:
>>>>
>>>>>
>>>>>
>>>>>
>>>>> Hi there,
>>>>>
>>>>> I want to write a front end to a DB, that has a search form, 
>>>>> WITHOUT
>>>>> writing
>>>>> code. I already successfully wrote a front end that can browse all
>>>>> elements,
>>>>> and add/remove/modify an entry with writing code.
>>>>>
>>>>> To avoid loading all the table that has 2 millions entries (hence 
>>>>> not
>>>>> "in
>>>>> memory" filtering with EOPickTextAssociation), I have to make a
>>>>> specific SQL
>>>>> query.
>>>>>
>>>>> Under EOBuilder, I have added a Fetch Spec to my table Entity
>>>>> In this Fetch Spec, I have added the Qualifier "(name = $myName)"
>>>>>
>>>>> But once under Interface Builder, I just can't find how to bind 
>>>>> user
>>>>> interface (NSField, NSForm) to my Query Variable (nyName).
>>>>> There is no @queryBindings->myName (or @bindings->myName) in the
>>>>> inspector
>>>>> (Inspector/Connections/EOTextAssociation) when binding to the
>>>>> EODisplayGroup
>>>>> that has my FetchSpec (like they talk about in the docs)
>>>>>
>>>>> Though, I have @query= (which seems to be the WOBuilder's
>>>>> @queryMatch). I
>>>>> was able to make a "simple search form", by binding my NSField to
>>>>> @QueryMatch->name. But the request which is made is case 
>>>>> insensitive,
>>>>> and
>>>>> not exact match, and I want to be able to execute complex sql 
>>>>> request
>>>>> as
>>>>> made in EOBuilder Fetch Spec.
>>>>>
>>>>> Does anyone know where are the "Query Variables"/@queryBidings in 
>>>>> the
>>>>> Interface Builder, how to bind them to interface elements, so that 
>>>>> I
>>>>> can
>>>>> execute a request without writing code ?
>>>>>
>>>>> Regards,
>>>>>     Ryu
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> EOF mailing list
>>>>> [email protected]
>>>>> http://www.omnigroup.com/mailman/listinfo/eof
>>>>
>>>
>>>
>>> _______________________________________________
>>> EOF mailing list
>>> [email protected]
>>> http://www.omnigroup.com/mailman/listinfo/eof
>>
>
>