Re: A method only refered to in the wod-file is called during invokeAction
Re: A method only refered to in the wod-file is called during invokeAction
- Subject: Re: A method only refered to in the wod-file is called during invokeAction
- From: Chuck Hill <email@hidden>
- Date: Tue, 10 May 2005 08:35:09 -0700
Hi Kaj,
On May 10, 2005, at 6:15 AM, Kaj Hejer wrote:
Hi!
We have a component with a WORepetition where list is bound to a
method in the component (lets call it getMyListElements). This method
is called during appendToResponse. This method is not refered to from
ANY place except for in the wod-file for this component.
Everything is good so far :)
But... this method is also called during invokeAction when I click a
link in the WORepetition that iterate over this array.
Yes, of course it is. The entire template is evaluated, with full
binding synchronization, at each of the three phases takeValues,
invokeAction, appendToResponse. takeValues is skipped if there is no
form submitted. See pages 201 to 207 in "the book" :-) for more
details.
The link is bound to a method where the currentItem for the repetition
is accessed like
public WOComponent doMyStuffWithCurrent() {
...
nextPage.setSelectedIdem(currentItem);
return nextPage;
}
A cardinal rule of methods called for binding synchronization is "Thou
shalt not have side effects".
I noticed that this method was called twice (when looking at
sql-debuginfo) and implemented invokeAction just calling super, but
with a debugstatement before and after the call to super, and there...
while beeing in super.invokeAction getMyListElements is called.
I have a debugstatement in doMyStuffWithCurrent too :) and I this
method is called after super.invokeAction has finished.
Can the access to currentSporreundersokelse trigger a call to the
method from which the array I iterate over?
I see this both with WO5.2.2 and WO5.2.4.
Has anybody here seen anything similar? Any ideas why the method is
called during invokeAction?
Because it is supposed to. :-) You will either need to remove the
side effect, or switch to manual binding synchronization where _you_
controll when it is called.
Chuck
--
Practical WebObjects - a book for intermediate WebObjects developers
who want to increase their overall knowledge of WebObjects, or those
who are trying to solve specific application development problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
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