Basic Cocoa Bindings in Java
Basic Cocoa Bindings in Java
- Subject: Basic Cocoa Bindings in Java
- From: Rémy Schumm <email@hidden>
- Date: Thu, 24 Mar 2005 14:43:32 +0100
Hi List
a very basic Question with Cocoa Bindings in Java:
I have a NSTextField which value is bound to e.g. werte.text where werte is a NSMutableDictionary in a content-Object:
NSTextField
Bind To: TestController (NSObjectController)
Controller Key: selection
Model Key Path: werte.text
The TestController's content outlet is connected to a Java Class that extends NSObject and has werte as an attribute with set and get and of type NSMutableDictionary.
- Using the GUI works perfectly: updating the GUI does all the other GUI Elements that are bound to this key path. Even binding the TestController to the Shared Defaults works perfectly.
BUT:
- The NSMutableDictionary does not get updated (unless I unbound the Shared Defaults from the TestController).
- Updating the NSMutableDictionary by programm with
werte.takeValueForKey("someText", "text");
does NOT update the GUI nor the Share Defaults.
In Java there is no "didChangeValueForKey" like in ObjC (or I cannot find them.)
=> has somebody an idea what I am doing wrong?
thanks in advance,
Rémy
The very basic controller:
import com.apple.cocoa.foundation.*;
import com.apple.cocoa.application.*;
public class TestController extends NSObject {
NSMutableDictionary werte;
public NSMutableDictionary werte(){
return werte;
}
public void setWerte(NSMutableDictionary d){
this.werte = d;
}
public void awakeFromNib(){
werte = new NSMutableDictionary();
}
public void dump(Object sender) { /* IBAction */
System.out.println("Alter Wert: " + werte.valueForKey("text"));
werte.takeValueForKey("Hallo", "text");
System.out.println("Neuer Wert: " + werte.valueForKey("text") + "\n\n");
}
}
--
Zürcher Hochschule Winterthur - ZHW
(Zurich University of Applied Science Winterthur, Switzerland)
Rémy Schumm, ZHW - T, E222, Postfach 805, 8401 Winterthur
dipl. Ing. FH, Assistent Softwareentwicklung, Dept. T,
tel. direkt +41 52 2677 490 gsm/mms/sms +41 79 21 1234 1
http://www.zhwin.ch/~smr - PGP ID 0x59BA4E81 - Mac OS X Panther on G5 Content Security by MailMarshal
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden