Re: Accessing args in an EOQualifier
Re: Accessing args in an EOQualifier
- Subject: Re: Accessing args in an EOQualifier
- From: "Daniele Corti" <email@hidden>
- Date: Tue, 24 Oct 2006 23:31:17 +0200
try this:
class Employee {
public String lastName;
public String firstName;
}
Employee employeeIn = new Employee();
employeeIn.lastName
= "Doe";
employeeIn.firstName = "John";
EOQualifier myQualifier;
NSMutableArray args = new NSMutableArray();
args.addObject(
employeeIn.lastName);
myQualifier =
EOQualifier.qualifierWithQualifierFormat("lastName = %s", args); //HERE CHANGE
System.out.println("qualifierKeys="+myQualifier.allQualifierKeys());
String employeeOut;
System.out.println("bindingKeys="+myQualifier.bindingKeys());
NSArray bindKeys = myQualifier.bindingKeys();
employeeOut =
bindKeys.lastObject().toString();
System.out.println("lastObject= "+employeeOut);
try, if it doesn't work, you should use the string:
EOQualifier.qualifierWithQualifierFormat
("lastName ="+employeeIn.lastName, null);
another thing, i always think it's better to not manipulate field directly, create 2 method lastName() and setLastName(String newLastname) and use these!
Daniele
2006/10/24, Carter Wojcik <email@hidden>:
Thanks for the help.
Below is the test code that I am using:
class Employee {
public String lastName;
public String firstName;
}
Employee employeeIn = new Employee();
employeeIn.lastName = "Doe";
employeeIn.firstName = "John";
EOQualifier myQualifier;
NSMutableArray args = new NSMutableArray();
args.addObject(employeeIn.lastName);
myQualifier =
EOQualifier.qualifierWithQualifierFormat("lastName =
$_lastName", args);
System.out.println("qualifierKeys=
"+myQualifier.allQualifierKeys());
String employeeOut;
System.out.println("bindingKeys=
"+myQualifier.bindingKeys());
NSArray bindKeys =
myQualifier.bindingKeys();
employeeOut = bindKeys.lastObject().toString();
System.out.println("lastObject= "+employeeOut);
Here is the output I get at runtime:
qualifierKeys= ("lastName")
bindingKeys= ("_lastName")
lastObject= _lastName
If I change the binding key from $_lastName to %@ I
get a runtime exception (nullpointerexception) when
displaying the component.
Here is that output:
qualifierKeys= ("lastName")
bindingKeys= ()
Thanks for all your help.
Carter
--- Daniele Corti <
email@hidden> wrote:
> yes, i understand, well I think you shold do
> something like this:
> String employeeLastname;
> NSArray bindKeys = myQualifier.bindingKeys();
> employeeLastname =
bindKeys.lastObject().toString;
>
> I think that will return anEmployee.lastName()
>
> 2006/10/24, Carter Wojcik <email@hidden>:
> >
> > Thanks for the pointers.
> >
> > It seems that bindingKeys() will return an array
> of
> > the known variables, which is close to what I
> would
> > like. Instead of the names of the variables, I
> would
> > like the actual objects that the variables
> represent.
> > I am creating my qualifier like the example below
> > (parts taken from API example):
> >
> > Employee anEmployee; // Assume this exists.
> > EOQualifier myQualifier;
> > NSMutableArray args = new NSMutableArray();
> > args.addObject(anEmployee.lastName());
> > myQualifier =
> > EOQualifier.qualifierWithQualifierFormat
> > ("lastName = %@", args);
> >
> > Sometime after myQualifier is set, I would like to
> > reverse engineer the qualifier and return the
> > anEmployee.lastName() object.
> >
> > Hope this makes more sense and is possible.
> >
> > Carter
> >
> > --- "Jerry W. Walker" <email@hidden
>
> wrote:
> >
> > > Hi, Carter,
> > >
> > > Check the method, "keyPathForBindingKey" in
> > > EOQualifier.
> > >
> > > Regards,
> > > Jerry
> > >
> > > On Oct 24, 2006, at 12:32 PM, Carter Wojcik
> wrote:
> > >
> > > > Hi All -
> > > >
> > > > I am creating an EOQualifier in a component
> that I
> > > am
> > > > then passing to a controller. The controller
> > > creates
> > > > a fetchspec using the qualifier and returns
> the
> > > > entities.
> > > >
> > > > I would like to deconstruct the fetch spec (in
> the
> > > > controller) by first getting the eoqualifier
> and
> > > then
> > > > the array of args that were supplied when the
> > > > qualifier was created. I can get the keys
> using
> > > > allQualifierKeys(), but does anyone know if it
> is
> > > > possible to access the actual objects that are
> > > being
> > > > used as the values to match?
> > > >
> > > > Thanks for your help.
> > > >
> > > > Carter
> > >
> > >
> > > --
> > > __ Jerry W. Walker,
> > > WebObjects Developer/Instructor for High
> > > Performance Industrial
> > > Strength Internet Enabled Systems
> > >
> > > email@hidden
> > > 203 278-4085 office
> > >
> > >
> > >
> > >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam
> protection around
> >
http://mail.yahoo.com
> > _______________________________________________
> > Do not post admin requests to the list. They will
> be ignored.
> > Webobjects-dev mailing list
> (
> >
> > This email sent to email@hidden
> >
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden