Re: Nested component communication
Re: Nested component communication
- Subject: Re: Nested component communication
- From: Jean-François Veillette <email@hidden>
- Date: Wed, 11 Aug 2004 15:00:50 -0400
I'm not sure but I think what they mean by 'no control' is because by
default, it synchronize the bindings before and after everyone of the 3
phases (ia, tvfr, atr).
I had a similar problem, I'll try to explain as to how I finally
understood what was going on. Please WO-guru, speak loudly if i'm
wrong.
Depending on where and what you do in your code, (for example, if you
do some sort of complex action on the setter, this will get called up
to 6 times !) you might set a value, but right after that WO will
synchronize this exact value with something else (most likely the old
value).
It does all this extra synchronisation because it tries to put the
subcomponent in the exact same context at wich the component expect it
to be. For WORepetition for example, if you have a list of member, and
a memberItem, it will set the memberItem as many times that there is
member in the list.
Imagine now that you have a subcomponent inside your worepetition, it
will try to put that sub-component those context as well, a context
that is relevent for the current iteration of the worepetition, and so
will ask to synchronize the binding. Imagine nested worepetition, or
any context similar to this one, and you got the reason why the is so
many extra synchronisation.
Make it a try, if you are not inside a worepetition, you have higher
chance (I do not know all the other context switching that will trigger
this extra synchronisation) of it simply working as expected. if you
do have your subcomponent nested in worepetition, then you will have to
think about it twice.
So if you push a value to another component, ask yourself if this new
value change the context WO think it is in. if it does change then you
can most likely assume that wo will somehow synchronize again a put the
value back.
To minimize the risk of problems, do you component communication
explicit and restrict it to the minimum only.
the problem (if any) will append on component receiving the value. it
might receive it multiple times.
good luck,
- jfv
Le 04-08-11, ` 12:25, David Holt a icrit :
Thanks Zak,
Your response makes me think that I should clarify my problem a little
better.
Variables pass from the component content to the Wrapper component
perfectly. I am using a pageTitle dynamically generated from the
componentContent binding.
My problem seems to be how to pass the variable from the
componentContent to its nested navigation bar and from the navigation
bar to its nested menu elements. Should I be using setter methods
explicitly? I think that the variable value is passing, but then is it
possible it is getting reset during the response loop? There is an
example in the old WebObjects Developer's Guide for version WO4.5 that
shows a parent component synchronizing to a child, and a child
synchronizing to the parent. The book says (on page 148): "For
instance, it's sufficient in the example shown in Figure 35 to simply
declare a childValue instance variable in the child component and a
parentValue instance variable in the parent." on the following page it
says: "Component synchronization can sometimes lead to values being
set when you don't want time to be set. You have no control over when,
or how often a value is passed to and from the parent."
Is there a better way for a nested element to know where it is (i.e.
which page level component is displaying it) and base its behaviour on
where it is?
On 11 Aug 2004, at 5:44 AM, Zak Burke wrote:
David,
Yeah, I've had a hard time tracking down details about
inter-component communication. Here's what works for me: In the api
file of the component which is being wrapped, you can directly set
the wrapper's variables like this:
WebObjectTagName: WrapperComponent {
var1 = "static string value";
var2 = aMethodValue;
}
This assumes that:
* the class WrapperComponent has variables var1 and var2. set-methods
probably work too, but I haven't tried
* the inner component's class has a method aMethodValue()
* var2 and the value returned by aMethodValue() are the same type
In your case, it sounds like you should be able to set the wrapper
class's "tabOne" variable from the wrapped pages, just like setting
var1 in the example above.
Good luck --
zak.
David Holt wrote on 8/10/04 6:52 PM:
Hello,
I am trying to get a navigation bar to work so that an image changes
when the user is on the page (like the tabs on Apple's site).
The way I have set it up is to have a page wrapper containing a
WOComponentContent and a NavigationBar Component made up of Rollover
components. In my API for the wrapper I have set a boolean variable
called "tabOne" and for all of the components that fill the
"WOComponentContent" under "tabOne" I have set their "tabOne"
binding to "true".
I have also placed "tabOne" variables in the wrapper component, the
NavigationBar component and the Rollover component. I have wrapped
the rollover button for tabOne in a conditional to display the
rollover when the boolean is false (i.e. not on a page that is in
tabOne) and a static image when the boolean is true. My problem is
that the boolean is always evaluating to false on pages where
"tabOne" is true and as a result only the rollover is displayed in
its conditional. From my reading, it seems that the component
communication is automatic from the parent components to child
components so long as the variables are named the same thing.
Am I misunderstanding something about how the communication would
occur from ComponentContent>Wrapper>NavigationBar>Rollover ? If so,
what would be a better way to implement this? Thanks,
David
_______________________________________________
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.
_______________________________________________
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.