At 11:59 AM -0800 3/8/99, Geoffrey Wiseman wrote:
> Standard caveat:
> I'm fairly new to WO, and while I've learned quite a bit in the last few
> weeks as I have spare moments, I'm probably still as likely to ask stupid
> questions as good ones.  I'm doing my work pretty much entirely in Java, and
> I don't know much about Objective-C or WebScript.  I'm using WO 4.0, in case
> that wasn't clear.
>
> Question:
> How the heck do I make an EOQualifier across a relationship?  I'll use the
> example I'm working with, simplified:  I have a table of rates that can be
> applied to particular companies at particular dates.  I want to filter the
> display group based on the company.  Reasonable enough, right?  So I begin
> to make an EOQualifier.  But then it occurs to me that I have no idea how to
> actually go about it in this case, since I want to filter it based on a
> relationship.
>
> Were I using pure SQL and ASP, I could just grab the primary key for the
> company in question and filter the rates based on the primary key.  However,
> in EOModeller, I've not made the pri key or the foreign key class
> properties, since they have no meaning other than maintaining the
> relationship.  This makes sense, of course, but it doesn't help me with my
> problem.
>
> So, let's say, for the sake of having terms to work with, I have a Rates
> table/object with a toCompany relationship defined based on the
> non-class-property "companyID" and a Companies table whose primary key is
> companyID.  I have a display group called dgRates which is connected to the
> rates table, and I want to qualify it based on a the users's company, which
> is known coming into the page.  Where do I go from here?


  A simple way to do this is to setup a master-detail displaygroup.

  Grab your dgRates display group, and configure it to say:


  has detail data source (check the box)
  Primary Entity: Company
  Relationship: torates.

  Then, in your code: rateDisplayGroup.setMasterObject(currentCompany).

  The docs don't explain what a master-detail display group is very 
well, but its really set up for doing the: "find all the records with 
this matching foreign key" kind of query. By setting the primary 
entity to "company" and the relationship to "torates", WO will figure 
out from your eomodel, that the display group is pointing to "Rate" 
objects. When you set the masterObject, that tells it what sort of 
companyID its looking for.

  Everything else works just like a regular displaygroup.

Pierce

  P.S.

   I wish there had been a "WebObjects for 
sprintf(queryString,"select * from rates where company=$d", 
company.id) hackers" book.
----------------------------------------------------------------
  Pierce T. Wetter III, Director, Twin Forces, Inc.
  e-mail: [EMAIL PROTECTED]  Phone:520-779-4227
  <http://www.twinforces.com/>
U.S. Mail: 1300 South Milton Rd, Suite 206, Flagstaff, AZ 86001

Reply via email to