Re: The most strange problem with bindings...
Re: The most strange problem with bindings...
- Subject: Re: The most strange problem with bindings...
- From: shaun <email@hidden>
- Date: Mon, 31 Jul 2006 22:57:04 +0930
Hi Miguel,
Miguel Arroz wrote:
Hi!
I'm having a bizarre problem relating to bindings, and I honestly
cannot understand why the heck this is happening. I can solve it easily
- or should I way, build a work-around - but I impose myself higher
levels of quality! ;)
Ok, here's the story:
1) I'm building an WO application that should work in two languages.
2) I have a WrapperComponent that wraps all the other components.
That wrapper component contains a repetition in the HEAD html code to
load JavaScript files. The repetition contains the path of the files to
be read (array of strings). That array (let's call it listOfFiles) is
on the WrapperComponent API.
3) WrapperComponent has another component inside,
NavigationComponent. That component has a form and a pop-up that allows
the user to select the language. The pop-up auto-submits when changed.
Basically, the code changes the session language array, and returns
"return pageWithName(context().page().name());"
4) I have a component, for the example, let's use the Main component.
The Main component contains a WrapperComponent, with some stuff inside.
On the Java code, I have a method "public NSArray scriptFiles()" that
returns an array with the file paths. There's no instance variable or
setter, naturally.
5) I have another component, let's call it "SimpleComponent", that
contains a WrapperComponent, but no scriptFiles array (and no binding).
WrapperComponent is smart enough to handle this OK.
Ok. Now imagine we are seeing Main component. Click on a link that
shows SimpleComponent. SimpleComponent appears OK. Now change the
language while SampleComponent is on the browser. A new instance of
SimpleComponent appears in the chosen language. Now, click on a link
that returns to Main component. So far, so good. This tells me that we
can enter and leave the Main component with no problems.
The problem happens on Main component, and any other one that has the
"listOfFiles" wrapperComponent binding binded to a component key. When
I change the language, I get this:
com.webobjects.foundation.NSKeyValueCoding$UnknownKeyException: [;
0.17 = ; } >; } >; 0.23 = ; 0.23.2.1.3 = ; 0.23.2.1.5 = ; 0.23.2.1.7 =
; } >; } >; } >; 0.29.1.1 = ; } > takeValueForKey()]: attempt to assign
value to unknown key: 'scriptFiles'. This WOComponent does not have an
instance variable of the name scriptFiles or _scriptFiles, nor a method
of the name setScriptFiles or _setScriptFiles
OK... for some reason, WO tries to set the scriptVars key. My
question is WHY!? There's absolutely no reason that I can see that
forces WO to do this. This apparently only happens when leaving a
component and entering another instance of that component class. But why!?
Of course, the work-around is easy, ant it works: just putting a
setScriptFiles method that does nothing is enough of a hack to make
this work. But that's not good enough. Why does this happen? Any tips?
In a nutshell, synchronizesVariablesWithBindings returns true, so your
parent and child components synchronize there variables and bindings. :)
Make your nested component non-synchronizing by overriding the method
synchronizesVariablesWithBindings and return false. Then implement the
valueForBinding method as you need to pull the binding values into the
nested component.
HTH.
- shaun
_______________________________________________
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