Re: Passing parameters on a binding
Re: Passing parameters on a binding
- Subject: Re: Passing parameters on a binding
- From: Jean-François Veillette <email@hidden>
- Date: Thu, 21 Oct 2004 21:17:43 -0400
the last couple of days and have been
trying to extend his validation solution a bit. What I have done is
added a method to my super component:
public boolean hasFailedValidationNamed(String key) {
return validationData.objectForKey(key) != null;
}
What I want to do is have a WOConditional in the page that can be
bound
to hasFailedValidationNamed and pass it in the key. Is this at all
possible?
Yes and no. It is not possible with plain old key-value coding. It is
possible using OGNL (ask Google), there is a framework in Project
Wonder
(WOOGNL) that wraps the OGNL library up for WO. I like it and it is
powerful, but it does add the potential for the binding version of
spaghetti code. You have been warned.
You can also use KVC to do what you want, without going fully with
OGNL, you can easily implement a working solution.
1-
in your binding, you could have
aCondition: WOConditional { condition = validationData.aKey; }
That would work if 'validationData' is a NSDictionary. without any
further work on your part. That's because NSDictionary does kvc by
giving value for a given key.
2-
If validationData is not a dictionary, you can overload kvc in your
component :
Object valueForKeyPath(String kp) {
if(kp.startWith("validationData.") {
String key = kp.substring(/* logic to get the key part after the
"validationData." part*/);
return validationData.objectForKey(key) != null;
}
else
return super.valueForKeyPath(kp);
}
Last time I looked at OGNL it was really big, kvc on serious steroid.
I didn't like how we needed to integrate our code with it, and didn't
need that much, so I decided to extend kvc in a different simpler
manner.
- jfv
_______________________________________________
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