Re: Hashtable to WOString?
Re: Hashtable to WOString?
- Subject: Re: Hashtable to WOString?
- From: David Teran <email@hidden>
- Date: Sun, 24 Oct 2004 12:39:43 +0200
I just tried your suggestion, and received a KVC error, which makes
sense. Hashtable doesn't implement KVC. That's okay, though. I'm
going to go back and change the original construction of the Hashtable
to make an NSDictionary instead. Though slower, it's easier to use in
WO.
It does not make sense that it throws just because if doesnt implement
KVC. Since WO5 KVC works with -any- object / class, you can for example
do this with a String:
WOString1: WOString {
value = myStringInstance.length;
}
This is because KVC uses its default implementation for classes /
objects which do not implement KVC. And: java.util.Vector can be used
instead of NSArray in repetitions which is why i hoped apple would have
implemented a comparable hack for the hashtable / map stuff but
obviously the didnt.
regards David
Thanks,
Nathan
On Oct 23, 2004, at 5:36 AM, David Teran wrote:
Well, did you try this:
aString: WOString {
value = myHashtable.keyName;
}
afaik this should work.
regards David
Am 23.10.2004 um 00:20 schrieb Nathan Dumar:
Aha! Number 2 is what I was hoping to hear. Thanks Colin!
Nathan
On Oct 22, 2004, at 6:00 PM, Colin Clark wrote:
Hi Nathan,
You're right, you can't pass arguments in WOComponent bindings, so
your first approach won't work. For any object that implements
Key-Value Coding, you could simply bind up the key name, such as
with an NSDictionary (eg. myDictionary.keyName). However, Hashtable
doesn't speak KVC, so there are a couple of other options:
1. Write an accessor in your WOComponent for that key of the
Hashtable:
public String getValueFromHashtable {
return myHashtable.get("keyName");
}
2. Convert your Hashtable into an NSDictionary. There's a
constructor available for that.
NSDictionary myDictionary = new NSDictionary(myHashtable);
I hope that helps,
Colin
On Friday, October 22, 2004, at 05:30 PM, Nathan Dumar wrote:
Is there an easy way of getting some text out of a Hashtable and
into a WOString? I thought that I could set the binding in
WOBuilder to aHashtable.get("key"), but that does not work.
If there's no simple way, then I'll just right a method to return
the String value.
Thank you,
Nathan
_______________________________________________
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
---
Colin Clark
Dynamic Web and Database Development Lead,
Resource Centre for Academic Technology,
University of Toronto
_______________________________________________
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
_______________________________________________
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