On Feb 23, 2011, at 2:34 PM, David Holt wrote: >> In the delegate class I put the following qualifierFromSenderMethod. >> >> private EOQualifier qualifierFromSender(ERD2WQueryPage sender) { >> NSMutableArray<Object> args = new NSMutableArray<Object>(); >> >> args.addObject(((Session)session()).schoolBoard().boardName()); >> args.addObject(((Session)session()).school().name()); >> EOQualifier qual = >> (EOQualifier.qualifierWithQualifierFormat( " schoolBoard.boardName = %@ and >> schools.name = %@ ", args)); >> ERXAndQualifier finalQual1 = new ERXAndQualifier(new >> NSArray<EOQualifier>(qual, sender.qualifier())); >> return finalQual1; >> } > > the code below assumes the use of the Wonder templates for EOGenerate > > private EOQualifier qualifierFromSender(ERD2WQueryPage sender) { > SchoolBoard sb = (((Session)session()).schoolBoard()); > School aSchool = (((Session)session()).school()); > EOQualifier q = > School_Admin.SCHOOLBOARD.eq(sb).and(School_Admin.SCHOOLS.eq(aSchool)).and(sender.qualifier()); > return q; > }
Hi Paul, Just a note to emphasize that the rewrite of your code that David Holt did above is and _excellent_ example of the much simpler code that can be written if you take advantage of Wonder. This code is not only simpler, but much safer as the compiler will watch your back and display an error if you decide to change the name of an entity, attribute or relationship in the model (EOQualifier.qualifierWithQualifierFormat is _evil_. Don't use it. It pushes errors out to run-time). Also, match on _EOs_ not strings or FKs/PKs if at all possible. It just simplifies your code and the less code you write the less chance there is for errors. Trust EOF to know what to do when comparing EOs. Dave
_______________________________________________ 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