Re: Pass-through bindings from parent to child component
Re: Pass-through bindings from parent to child component
- Subject: Re: Pass-through bindings from parent to child component
- From: Paul Hoadley <email@hidden>
- Date: Tue, 8 Jan 2008 09:37:13 +1030
Hi Chuck,
On 08/01/2008, at 4:38 AM, Chuck Hill wrote:
Maybe I've wandered too far down the wrong path here, so I'll ask a
different question. For now, the only additional functionality I'm
trying to add to the dynamic elements is the classList() method
referred to in the WOD above. (This returns a string containing a
space-separated list of classes which ends up as the value of the
HTML "class" attribute for CSS styling.) So I've created an
LSComponent which extends WOComponent and implements classList().
So currently LSBrowser extends LSComponent. If I have LSBrowser
extend WOBrowser (or WODynamicElement), I'm going to need to
duplicate classList() in LSTextField, LSCheckBox, and so on. Am I
going about this (adding a method to the standard dynamic elements)
the wrong way?
I can't think of a way to add methods to the standard elements
without re-implementing them. But perhaps you are going about
implementing CSS in the wrong way. I must admit that I am not
seeing part of this picture. When I use a WOBrowser, I might have
something like this:
class = "boxOutline requiredField formFont";
I am guessing that you are deriving classList in some other manner.
Not having any idea how you have done that, I would suggest moving
the logic elsewhere. It if is sufficiently static, you could put it
in an NSDictionary in application, keyed on the element name.
It is sufficiently static. I think I was trying to over-generalise my
solution by using a single method in my LSComponent class. This is a
much better idea:
Then you could use a binding on WOBrowser like
application.cssClassesFor.WOBrowser;
where cssClassesFor is a public method on Application that returns
an NSDictionary.
Another thing to consider is to override this method on Application:
public WOElement dynamicElementWithName(String aName,
NSDictionary someAssociations,
WOElement anElement,
NSArray aLanguageArray)
and add your class = whatever binding to the someAssociations
dictionary like so:
if ( someAssociations.objectForKey("class") == null) {
NSMutableDictionary associations = someAssociations.mutableClone();
associations.setObjectForKey(new
WOKeyValueAssociation("application.cssClassesFor.WOBrowser"),
"class");
}
That way, you can override the classes on the element, but it you do
not specify the class then you get the default.
Thanks Chuck.
--
Paul.
w http://logicsquad.net/
h http://paul.hoadley.name/
_______________________________________________
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