Re: Semantics of ^ in value bindings in .wod file.
Re: Semantics of ^ in value bindings in .wod file.
- Subject: Re: Semantics of ^ in value bindings in .wod file.
- From: Archibal Singleton <email@hidden>
- Date: Wed, 2 Jan 2008 16:19:59 -0300
Me again, I'm trying to make sense of the ^ thing %-)
Thanks to Art (see his previous email in this thread) I found some
very valuable information in some legacy WO docs from Apple, namely
the WebObjects Developer Guide re: component synchronization and stuff.
I'd strongly recommend this documentation to other newbies, although
it's not current, as Art mentioned there's a lot of information about
the more conceptual aspects of WO in there.
http://developer.apple.com/documentation/LegacyTechnologies/WebObjects/WebObjects_4.5/System/Documentation/Developer/WebObjects/DevGuide/WebObjectsDevGuide.pdf
One thing I'm not sure about is wether it's possible to use the ^
syntax for non-synchronizing component.
Lot's of examples in both the WOnder and Apple examples seems to
indicate that it's possible. But I've tried to create the simplest
project to make this work...
... and it doesn't :-(
My project has two components Main and a sub-component UserName.
The child component, UserName just has a WOTextField".
--- UserName.html
The user Name <webobject name = "userName"/>
--- UserName.wod
userName : WOTextField {
value = ^userName;
}
---
Its java file is the boiler plate file generated by WOLips.
Main is the parent component.
--- Main.html
...
<webobject name = "MyForm">
<webobject name = "UserName"/>
<webobject name = "SubmitButton"/>
</webobject>
--- Main.wod:
MyForm : WOForm {
action = greetUser;
}
UserName: UserName {
userName = theUserName;
}
SubmitButton : WOSubmitButton {
action = greetUser;
}
--- Main.java
...
private String theUserName;
public String getTheUserName() {
return theUserName;
}
public void setTheUserName(String s) {
theUserName = s;
}
public WOComponent greetUser() {
return null;
}
So this is really the most basic subcomponent set up.
I'm using Eclipse 3.3.2 Build id: M20071205-0800 / WOLips 3.3.4753.
My app is a WOnder app.
When I run, it crashes with the stack trace below.
Apparently, it's complaining that the UserName component does not have
a key...
But that's the whole idea, it should be using it's parent's key!
Now if I override synchronizesVariablesWithBindings() in UserName.java
to return false, everything works.
But I see lots of examples (e.g. WOTable and WOCheckboxMatrix) where
subcomponent using the ^ don't override
synchronizesVariablesWithBindings() to return false. And I assume that
they work (I haven't tested them).
What am I missing here?
Many thanks for any help.
= tmk =
2008-01-02 16:01:13 ] <WorkerThread0>
<com.webobjects.appserver._private.WOComponentRequestHandler>:
Exception occurred while handling request:
com.webobjects.foundation.NSKeyValueCoding$UnknownKeyException:
[<wo.learning.components.UserName name:
wo.learning.components.UserName subcomponents: null >
takeValueForKey()]: attempt to assign value to unknown key: 'userName'.
This WOComponent does not have an instance variable of the name
userName or _userName, nor a method of the name setUserName or
_setUserName
[2008-01-02 16:01:13 ] <WorkerThread0>
com.webobjects.foundation.NSKeyValueCoding$UnknownKeyException:
[<wo.learning.components.UserName name:
wo.learning.components.UserName subcomponents: null >
takeValueForKey()]: attempt to assign value to unknown key: 'userName'.
This WOComponent does not have an instance variable of the name
userName or _userName, nor a method of the name setUserName or
_setUserName
at
com
.webobjects
.appserver.WOComponent.handleTakeValueForUnboundKey(WOComponent.java:
1580)
at com.webobjects.foundation.NSKeyValueCoding
$Utility.handleTakeValueForUnboundKey(NSKeyValueCoding.java:568)
at com.webobjects.foundation.NSKeyValueCoding
$_KeyBinding.setValueInObject(NSKeyValueCoding.java:925)
at com.webobjects.foundation.NSKeyValueCoding
$DefaultImplementation.takeValueForKey(NSKeyValueCoding.java:1293)
at
com.webobjects.appserver.WOComponent.takeValueForKey(WOComponent.java:
1550)
at
com
.webobjects
.appserver.WOComponent.pullValuesFromParent(WOComponent.java:533)
at
com
.webobjects
.appserver
._private
.WOComponentReference
._pushComponentInContext(WOComponentReference.java:84)
at
com
.webobjects
.appserver
._private
.WOComponentReference.appendToResponse(WOComponentReference.java:110)
at
com
.webobjects
.appserver
._private.WODynamicGroup.appendChildrenToResponse(WODynamicGroup.java:
121)
at
com
.webobjects
.appserver._private.WOForm.appendChildrenToResponse(WOForm.java:124)
at
com
.webobjects
.appserver
._private
.WOHTMLDynamicElement.appendToResponse(WOHTMLDynamicElement.java:424)
at
com.webobjects.appserver._private.WOForm.appendToResponse(WOForm.java:
118)
at
com
.webobjects
.appserver
._private.WODynamicGroup.appendChildrenToResponse(WODynamicGroup.java:
121)
at
com
.webobjects
.appserver
._private.WODynamicGroup.appendToResponse(WODynamicGroup.java:130)
at
com.webobjects.appserver.WOComponent.appendToResponse(WOComponent.java:
992)
at wo.learning.components.Main.appendToResponse(Main.java:44)
at com.webobjects.appserver.WOSession.appendToResponse(WOSession.java:
1200)
at
com
.webobjects
.appserver.WOApplication.appendToResponse(WOApplication.java:1418)
at
com
.webobjects
.appserver
._private
.WOComponentRequestHandler
._dispatchWithPreparedPage(WOComponentRequestHandler.java:230)
at
com
.webobjects
.appserver
._private
.WOComponentRequestHandler
._dispatchWithPreparedSession(WOComponentRequestHandler.java:287)
at
com
.webobjects
.appserver
._private
.WOComponentRequestHandler
._dispatchWithPreparedApplication(WOComponentRequestHandler.java:322)
at
com
.webobjects
.appserver
._private
.WOComponentRequestHandler
._handleRequest(WOComponentRequestHandler.java:358)
at
com
.webobjects
.appserver
._private
.WOComponentRequestHandler
.handleRequest(WOComponentRequestHandler.java:432)
at
com
.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:
1306)
at
com
.webobjects
.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java:173)
at
com
.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:
254)
at java.lang.Thread.run(Thread.java:613)
On 31 Dec 2007, at 16:03, Archibal Singleton wrote:
Thank you very much indeed for your explanation Anjo. Much
appreciated.
You're right indeed that the valueForBinding() already gets the
binding from the parent so parent().valueForBinding() would get the
binding from "grand-parent" of the component.
Cheers,
= tmk =
On 29 Dec 2007, at 16:14, Anjo Krank wrote:
Am 29.12.2007 um 18:57 schrieb Archibal Singleton:
^foo in the wod is the same as parent().valueForBinding("foo") in
java
parent.foo in the wod is the same as parent.valueForKey("foo") in
java
The first line requires a parent with foo bound. The second line
requires a variable or method named foo.
Thanks for the clarification Uli, the nuance is indeed important
and I didn't get it at first.
It's important and unfortunately is not quite right. Assume your
parent java has:
public String hello() {return "Hello"}
The parent wod has
MySub : MySub {
foo = hello;
}
The child MySub has:
MyFoo : WOString {
value = ^foo;
}
Then you get whatever your parent has bound against the child
instance's "foo" binding. This is NOT the same as
parent().valueForBinding("foo"), which would get what the parent of
the parent of MySub had bound to "foo".
It mainly a shortcut so you don't have to write in the child java:
public Object foo() {return valueForBinding("foo")}
and in the child wod:
MyFoo : WOString {
value = foo;
}
I'm normally not picky about stuff, but this IS an important
concept and in particular valueForKey() and valueForBinding() can
be hard to tell apart...
Cheers, Anjo
_______________________________________________
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