Re: action binding with conditionals
Re: action binding with conditionals
- Subject: Re: action binding with conditionals
- From: Chuck Hill <email@hidden>
- Date: Tue, 08 Apr 2003 20:44:07 -0700
Or you can look at is like an alternative OO binding mechanism. For most
OO languages object A knows about object B and what it can do and sends
messages directly to it. But this isn't the only paradigm. Another one is
that an object A just knows about messages. When it wants something done
it just sends (broadcasts?) a message. It is the responsibility of object
B, or any object that can handle the message, to recognize that it should
handle the message and do so. Google 'Message Bus' for a distributed
variant of this.
This is somewhat the way that invoking actions on a web page works. As the
HTML on the page has no direct connection to the objects on the server
there must be some mechanism to connect the two. If you look at the source
of a web page you will see that most of the dynamic components have a name
like 1.2.3.4.5 This is the message that is passed, via http, back to the
server when you click a link or button in the browser. While WO could have
a dictionary associating each name with the method of an object, it doesn't.
During invokeAction it broadcasts the message (name, a.k.a. element ID) to
all the components in the template and trusts the right one to respond.
(I'm playing a little fast and loose with all the details here) As each
object receives this message it either returns a response to indicate that
the message was for it and has been handled, or returns null indicating
that the message was not for it. If an object has children (e.g. a form
has form elements as its children, a WOConditional has other WOComponents
as its children) and the message is not for it, it sends the message onto
its children. At the end of the broadcast, if no object returns a non-null
response then the page is redisplayed as a default action.
A WOConditional considers that it does not have any children if the value
it is bound to returns false. Thus you must be careful changing this value
during the takeValues phase as the WOConditional will "disown" its children
if the condition becomes false.
My usual way of handling these situations is to set a flag during
takeValues and check it and change the values in appendToResponse before
calling super. This also applied to the situation of removing items from
an array bound to a WOReptition. Doing so in takeValues (due to a box
being checked for example) can lead to errors in later phases. This also
must be delayed.
Chuck
At 09:26 AM 08/04/2003 -1000, Art Isbell wrote:
>On Tuesday, April 8, 2003, at 06:14 AM, Richard L. Peskin wrote:
>
>> I think my confusion is that a
>> WOComponent (e.g. Submit button) is an object and the action is bound
>> to that object. The "event" (pressing the button) is handled by the
>> user's browser (doing the usual form data submission, etc.). It looks
>> like this button press sends a message to the Submit button object,
>> which in turn will deal with bound actions depending on conditionals.
>> Does this sound correct?
>
> For me, it's easier to consider what happens during WO's component
>template parsing. If the evaluation of a conditional results in the
>button that was clicked not being parsed in the template, then the
>action associated with the button won't be invoked. While one might be
>able to make sense out of this behavior by thinking of it in
>object-oriented terms, I'm not confident that this view would always
>lead to the correct interpretation. It's unfortunate that WO's rather
>low-level operations should be understood well, but considering what
>NeXT's WO designers were able to accomplish using the rather archaic
>Web architecture, it's rather amazing that things work as well as they
>do.
>
>Aloha,
>Art
>_______________________________________________
>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
_______________________________________________
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.