Re: overriding certain NSKeyValueCoding methods in EOs
Re: overriding certain NSKeyValueCoding methods in EOs
- Subject: Re: overriding certain NSKeyValueCoding methods in EOs
- From: Chuck Hill <email@hidden>
- Date: Mon, 16 Apr 2007 09:48:30 -0700
Florijan,
You are violating the virginal purity of EOF will be burn in the hell
of EOF stack traces for all eternity.
Happy now? :-)
Seriously, what you are doing seems quite OK. KVC is just a way of
translating a string into a value. How you choose to the the
translation is up to you. I am certain that you can find something
that will break something else, but you will have to work at it. I
make quite a bit of use of KVC extensions for purposes as does
WireHose and (I think) Wonder.
Here is a fun alternative to declaring public instance variables to
hold binding values in a WOComponent subclass:
public NSMutableDictionary dynamicData = new NSMutableDictionary();
public Object handleQueryWithUnboundKey(String key) {
Object result = dynamicData.objectForKey(key);
// Helps to find typing errors in bindings
if (result == null) NSLog.out.appendln("no value found for key "
+ key);
return result;
}
public void handleTakeValueForUnboundKey(Object value, String key) {
dynamicData.setObjectForKey(value, key);
}
Chuck
On Apr 16, 2007, at 6:42 AM, Florijan Stamenkovic wrote:
Hi Pierre,
Thanks for the reply. I think that would be a good point to try to
implement this. And as nobody came up with "this will break EOF and
you will burn in WO hell for all eternity", I suppose the idea is
worthwhile trying out.
Cheers,
Flor
Take a look at this:
http://developer.apple.com/documentation/WebObjects/Reference/API/
com/webobjects/foundation/
NSKeyValueCoding.ErrorHandling.html#handleQueryWithUnboundKey
(java.lang.String)
Pierre Bernard
Houdah Software s.à r.l.
On Apr 15, 2007, at 1:50 PM, Florijan Stamenkovic wrote:
Hi all,
I have an idea, but am not sure if it would be EOF acceptable.
Essentially, I would like to expand the KVC system somewhat. The
point would be this:
public Object valueForKey(String key){
try{
return super.valueForKey(key);
}catch(Exception ex){
Object rVal = valueForCustomKey(key);
if(rVal != null) return rVal;
throw ex;
}
}
public Object valueForCustomKey(String key){
// find a key in another system as EOF's KVC
...
}
So, if there is not EOF result for a key, try the additional
implementation. It would be ideal of course to get this to work
with the rest of KVC, to enable sums, counts, and all that stuff
on custom keys as well. What I am thinking / hoping at the moment
is that KVC is implemented so that for retrieving and setting
values for keys it relies on a narrow set of methods
(NSKeyValueCoding interface only???)...
Any words of wisdom?
Thanks!
Florijan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
- - -
Houdah Software s. à r. l.
http://www.houdah.com
- Quality Mac OS X software
- Premium WebObjects consulting
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net
This email sent to email@hidden
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
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