Re: Access bindings at runtime
Re: Access bindings at runtime
- Subject: Re: Access bindings at runtime
- From: Chuck Hill <email@hidden>
- Date: Tue, 03 Feb 2004 13:34:00 -0800
- Organization: Global Village Consulting, Inc.
I'm still a little confused on how you want this to work. Maybe an
example will help me. Let's imagine a string:
DateTitle : WOString {
value = "Today's date is";
}
I'm not clear on what binding you want, or what you are going to do
with it. I would start by looking at something like this:
DateTitle : WOString {
value = session.localizedString.todaysDateIs;
}
Then in session add the method:
public String localizedString(String key) {
String localizedString = null;
for (int i = 0; localizedString == null && i <
languages().count(); i++) {
localizedString = stringInLocale(key,
languages().objectAtIndex(i));
}
return localizedString;
}
And implement stringInLocale to look up the localized version in the
database (I'd cache it in memory for performance reasons) and return
null if there is no version.
Chuck
David Griffith wrote:
Hi Chuck,
I am trying to create a custom localisation technique - I want to identify
each dynamic element on the component by name, so that when I bind a
variable to a dynamic element, I can get a logical reference to look up the
text from a database by cross referencing it with the language.
Yes, I know WebObjects has some built in localisation, but from what I have
read it is not very flexible. We will be supporting many, many languages
and I want to ensure we have full control over it.
If you have (or anyone else for that matter has) a better way of doing this,
please do feel free to let me know. Obviously there are many rollovers that
need localising as well as text elements etc. I also want to be able to
update these things via a database rather than directly through the
localisation files of WO.
Any suggestions are very welcome.
Regards,
Dave.
What, specifically, is it that you are trying to accomplish by doing
getting such access? It seems that you might be trying to do
something the wrong way...
Chuck
David Griffith wrote:
Hi Jonathan,
Having had a closer look, I think that method will only return the bindings
of the component rather than the bindings of each dynamic element. I'll
take a look at it more closely - any other suggestions?
Regards,
Dave.
Jonathan,
Thanks for that - I should have thought of looking there, still having a
little trouble finding my way around WO. I think that's exactly what I was
looking for - what I was wondering is, will WO complain if I add a binding
to each Dynamic Object called, for example, myName and bind the name I want
it to have to that? Like, myName="header". I will try it and see, if it
does not complain about 'nonsensical' bindings, I think this will solve my
problem.
Cheers!
Dave.
David Griffith, email@hidden, wrote:
I need to access the name of the element, but from other posts I have seen
apparently that is not possible. So I was wondering if I could bind an
internal name of my own to a custom binding for each element so that I
could
access it at runtime. I need to lookup some data in the db based on this
name.
I don't fully understand what you're trying to accomplish, but I want to
ensure you know about this method:
<http://developer.apple.com/documentation/WebObjects/Reference/API/com/webo
bjects/appserver/WOComponent.html#bindingKeys()>
I think this will enable you to discover all of a component's bindings at
runtime.
.......................................................
Jonathan 'Wolf' Rentzsch http://rentzsch.com
Red Shed Software http://redshed.net (847) 584-7465
PGP: b2af 1a09 f881 ebde c9d6 c4d2 c04f a3c0 3ec5 d5f2
"better" necessarily means "different"
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
--
Chuck Hill email@hidden
Global Village Consulting Inc. http://www.global-village.net
It is a funny thing about life; if you refuse to accept
anything but the best, you very often get it."
-- W. Somerset Maugham
<shamelessPlug>
Practical WebObjects
http://www.amazon.com/exec/obidos/tg/detail/-/1590592964
</shamelessPlug>
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.